Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
When event inconsistency?
Message
 
To
07/12/2005 14:59:10
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01075534
Message ID:
01075869
Views:
19
Ok, so this makes my scenario consistent: for CommandButton, Checkbox,... Click always triggers Valid, which is always followed by a second When.
What do you think, is this a bug, or is it a bad design choice caused by trying to fit Valid in the event list of CommandButton, Checkbox,... ?
Do we need Valid for a CommandButton in VFP? BTW, I still don't understand what do you mean when you say that return .F. in Valid is ignored?

>>Hi Fabio,
>>It looks like the Click event for CommandButton, Checkbox, combobox, listbox, optiongroup,... by design, triggers the Valid event. Valid, normally fires when a control loses focus, but because when you click on a control focus must stay on the control, when fires the second time.
>
>>However, if the CommandButton has the focus, Click doesn't trigger Valid...
>
>??? sure ???
>
>ACTIVATE WINDOW "debug Output"
>SET EVENTLIST TO Click,Valid,When,Message,InteractiveChange
>SET EVENTTRACKING ON
>
>loForm = createobject('zForm')
>loForm.show
>
>FOR k=1 TO 20
>	CHRSAW(0.2)
>	KEYBOARD  '{SPACEBAR}' PLAIN CLEAR
>	DOEVENTS
>NEXT
>
>
>
>define class zForm as form
>	Caption = "Click on When button"
>	Name = "Form1"
>	Autocenter = .T.
>	Width = 360
>	Height = 150
>	visible = .t.
>
>	ADD OBJECT text1 AS textbox WITH ;
>		Height = 23, ;
>		Left = 20, ;
>		Width = 80, ;
>		TabIndex = 2, ;
>		Top = 10, ;
>		Name = "Text1", ;
>		enabled = .F.,;
>		value = 0
>	ADD OBJECT command1 AS COMMANDBUTTON WITH ;
>		Top = 10, ;
>		Left = 140, ;
>		Height = 27, ;
>		Width = 120, ;
>		Caption = "When", ;
>		TabIndex = 1, ;
>		Name = "Command1"
>
>	ADD OBJECT label1 AS label WITH ;
>		top = 44, ;
>		left = 20, ;
>		width = 250, ;
>		wordwrap = .T., ;
>		autosize = .t., ;
>		Caption = "When event fires twice when the button does not have focus before click!!?"
>	ADD OBJECT label2 AS label WITH ;
>		top = 84, ;
>		left = 20, ;
>		width = 250, ;
>		wordwrap = .T., ;
>		autosize = .t., ;
>		Caption = "When event fires once when the button has focus before click!!?"
>
>	PROCEDURE command1.Valid
>		RETURN .F.	&& this is ignored
>	ENDPROC
>
>* workaround
>*		PROCEDURE command1.Click
>*			NODEFAULT
>*		ENDPROC
>
>	PROCEDURE command1.valid
>		thisform.text1.value = thisform.text1.value + 1
>	ENDPROC
>
>	PROCEDURE load
>		ADDPROPERTY(this,"lock",this)
>ENDDEFINE
>
>
Doru
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform