Re: Weird Behavior of OnLostFocus
Posted: Thu Sep 20, 2012 10:51 am
Rathi,
is lostfocus event not work well with 'Setfocus' method ? I am experiencing some problem using 'Setfocus' in lostfocus event.
Can u help me plz ?
My sample code is as above , I want to setfocus of text_1 field if text_2 value is 100
Thanks in advance.
#include "hmg.ch"
*
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 940 HEIGHT 480 ;
TITLE 'Lostfocus Test' ;
MAIN
@ 10,10 LABEL lbl_ERRMSG ;
VALUE ""
@ 110,10 TEXTBOX Text_1 ;
VALUE 123 ;
NUMERIC ;
ON LOSTFOCUS SHOWMSG1("text_1")
@ 150,10 TEXTBOX Text_2 ;
VALUE 123 ;
Numeric ;
ON LOSTFOCUS SHOWMSG1("text_2")
@ 200,10 TEXTBOX Text_3 ;
VALUE 123 ;
Numeric ;
ON LOSTFOCUS SHOWMSG1("text_3")
END WINDOW
Form_1.Center
Form_1.Activate
Return Nil
*******************************
FUNCTION SHOWMSG1(mxErrMsg)
mtmp := space(10)
mxyWindName := ThisWindow.Name
mxyCntrName := "Lbl_ERRMSG"
SetProperty(mxyWindName,mxyCntrName,"Value","Displaying "+mxErrMsg)
mxSec := Seconds()
DO WHILE (Seconds() - mxSec) < 1
ENDDO
SetProperty(mxyWindName,mxyCntrName,"Value","")
*
mTmpVal := Form_1.Text_2.value
IF (mxErrMSg = "text_2") .and. (mTmpVal = 100)
mxyCntrName := "Text_2"
DOMETHOD(mxyWindName,mxyCntrName,"SetFocus")
ENDIF
*
RETURN NIL
**********************************
is lostfocus event not work well with 'Setfocus' method ? I am experiencing some problem using 'Setfocus' in lostfocus event.
Can u help me plz ?
My sample code is as above , I want to setfocus of text_1 field if text_2 value is 100
Thanks in advance.
#include "hmg.ch"
*
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 940 HEIGHT 480 ;
TITLE 'Lostfocus Test' ;
MAIN
@ 10,10 LABEL lbl_ERRMSG ;
VALUE ""
@ 110,10 TEXTBOX Text_1 ;
VALUE 123 ;
NUMERIC ;
ON LOSTFOCUS SHOWMSG1("text_1")
@ 150,10 TEXTBOX Text_2 ;
VALUE 123 ;
Numeric ;
ON LOSTFOCUS SHOWMSG1("text_2")
@ 200,10 TEXTBOX Text_3 ;
VALUE 123 ;
Numeric ;
ON LOSTFOCUS SHOWMSG1("text_3")
END WINDOW
Form_1.Center
Form_1.Activate
Return Nil
*******************************
FUNCTION SHOWMSG1(mxErrMsg)
mtmp := space(10)
mxyWindName := ThisWindow.Name
mxyCntrName := "Lbl_ERRMSG"
SetProperty(mxyWindName,mxyCntrName,"Value","Displaying "+mxErrMsg)
mxSec := Seconds()
DO WHILE (Seconds() - mxSec) < 1
ENDDO
SetProperty(mxyWindName,mxyCntrName,"Value","")
*
mTmpVal := Form_1.Text_2.value
IF (mxErrMSg = "text_2") .and. (mTmpVal = 100)
mxyCntrName := "Text_2"
DOMETHOD(mxyWindName,mxyCntrName,"SetFocus")
ENDIF
*
RETURN NIL
**********************************