Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Possible bug in Lost Focus when using access keys / hot
Message
From
16/10/2002 15:48:54
 
 
To
16/10/2002 15:30:19
Jonathan Cochran
Alion Science and Technology
Maryland, United States
General information
Forum:
Visual FoxPro
Category:
Troubleshooting
Miscellaneous
Thread ID:
00711927
Message ID:
00711936
Views:
13
>I've noticed the following problem in VFP 6 SP3. Can someone confirm it, especially in VFP 7? If you put NODEFAULT in the LostFocus method, there should be no way for the control to lose focus, right? It appears that if you press the access key / hot key of another control, you can move focus to that control.

Yes, that's true, and how it works in 7.0. It is somewhat unexpected, I suppose, though not too surprising. The control doesn't actually lose focus, the click executes, but the focus remains on the textbox (see my example below). What you're trying to do is what the Valid() is designed for, however, and belongs in the valid.
LOCAL loForm AS FORM
loForm = NEWOBJECT('MyForm')
loForm.SHOW(1)

DEFINE CLASS MyForm AS FORM
	ADD OBJECT MyTextBox AS MyTextBox
	ADD OBJECT MyButton AS MyButton WITH TOP = 30
ENDDEFINE

DEFINE CLASS MyTextBox AS TEXTBOX

	VALUE = ""
	
	*!* Use valid instead of lostFocus
	PROCEDURE VALID
		DEBUGOUT PROGRAM() + " Value = " + THIS.VALUE
		IF EMPTY( THIS.VALUE )
			RETURN 0
		ENDIF

	ENDPROC

*!*		PROCEDURE LOSTFOCUS
*!*			DEBUGOUT PROGRAM() + " Value = " + THIS.VALUE
*!*			IF EMPTY( THIS.VALUE )
*!*				NODEFAULT
*!*			ENDIF

*!*		ENDPROC

ENDDEFINE

DEFINE CLASS MyButton AS COMMANDBUTTON

	CAPTION = "\<OK"

	PROCEDURE CLICK
		DEBUGOUT PROGRAM()
	ENDPROC

ENDDEFINE
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform