Page 1 of 1

Se me olvidaba

Posted: Sun Jun 24, 2012 11:21 pm
by paimar
Se puede saber al perder el foco un textbox (lostfocus) si ha sido por pulsar la tecla Escape?

gracias

Un saludo

Re: Se me olvidaba

Posted: Fri May 16, 2014 8:50 pm
by Pablo César
Si, puedes hacerlo. Tengo dos formas para indicarte:

1. Es crear un evento y verificar si la tecla ES fué presionada.
2. Hacer disparar una funcion al presionar ESC.

Code: Select all

#include "hmg.ch"

Function Main

	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 HEIGHT 480 ;
		TITLE 'HMG Demo' ;
		MAIN
		
		ON KEY ESCAPE ACTION SeeWhatHappen(.T.)

		@ 10,10 TEXTBOX Text_1 ;
			VALUE 123 ;
			TOOLTIP 'Numeric TextBox (MAXLENGTH 5)' ;
			NUMERIC ;
			MAXLENGTH 5 ;
			RIGHTALIGN ;
			ON LOSTFOCUS SeeWhatHappen(.F.) // if ( This.Value < 100 , This.SetFocus , Nil)


		@ 40,10 TEXTBOX Text_2 ;
			VALUE 'Hi All' ;
			TOOLTIP 'Character TextBox' ;
			DISABLEDBACKCOLOR { 0,255,0 } ;
			DISABLEDFONTCOLOR { 255,255,255 } 

	END WINDOW

	Form_1.Center

	Form_1.Activate

Return Nil

Function SeeWhatHappen(lPressed)
If lPressed
   MsgInfo("ESC was pressed !")
Endif
Return Nil