Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
When event inconsistency?
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
When event inconsistency?
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01075534
Message ID:
01075534
Vues:
52
I believe I've seen this on UT but I can't find it... Why does WHEN event for a command button fire twice when it does not have focus before it is clicked?
loForm = createobject('zForm')
loForm.show
read events

define class zForm as form
	Caption = "Open debugout, and 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 = 1, ;
		Top = 10, ;
		Name = "Text1", ;
		value = 0
	ADD OBJECT command1 AS commandbutton WITH ;
		Top = 10, ;
		Left = 140, ;
		Height = 27, ;
		Width = 120, ;
		Caption = "When", ;
		TabIndex = 2, ;
		Name = "Command1"
	ADD OBJECT command2 AS commandbutton WITH ;
		Top = 110, ;
		Left = 280, ;
		Height = 27, ;
		Width = 60, ;
		Caption = "Exit", ;
		TabIndex = 3, ;
		Cancel = .T.
		Name = "Command2"
	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.When
		debugout this.Name,program()
		thisform.text1.value = thisform.text1.value + 1
	ENDPROC
	PROCEDURE command1.GotFocus
		debugout this.Name,program()
	endproc
	PROCEDURE command2.When
		debugout this.Name,program()
	ENDPROC
	PROCEDURE command2.click
		thisform.release
		clear events 
	endproc
enddefine
Doru
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform