Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BIG BUG: with Valid() .F. textbox can lose focus.
Message
 
 
To
26/11/2003 09:35:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00853662
Message ID:
00853725
Views:
19
To keep focus on the object, try RETURN 0 instead. This also gives you better control on what kind of alert you present to the user in the form of an error message.

>Hi,
>
>i use RETURN .F. on the Valid() event,
>so that the control does not lose focus
>when the input value is not valid.
>
>This is ok within a form, but with 2 or more forms :
>i can lose focus with a not valid value, and this is written on the Controlsource
>
>Repro code:
>
>PUBLIC ovalidviolation,oanother
>
>ovalidviolation=NEWOBJECT("valid_violation")
>oanother			=NEWOBJECT("another")
>ovalidviolation.Show
>oanother.Show
>RETURN
>
>DEFINE CLASS valid_violation AS form
>	Top = 10
>	Left = 10
>	Caption = "Form with valid check"
>
>	ADD OBJECT text2 AS textbox WITH ;
>		Left = 109, ;
>		Top = 54
>		
>	ADD OBJECT text1 AS textbox WITH ;
>		Left = 109 ;
>	,	Top = 14	;
>	,	Controlsource = "thisform.text2.Value"
>
>	ADD OBJECT label1 AS label WITH ;
>		AutoSize = .T., ;
>		Caption = "Valid if empty()", ;
>		Left = 18, ;
>		Top = 15
>
>	ADD OBJECT label2 AS label WITH ;
>		AutoSize = .T., ;
>		Caption = "ControlSource", ;
>		Left = 18, ;
>		Top = 55
>
>	PROCEDURE text1.Valid
>		RETURN EMPTY(m.this.value)
>	ENDPROC
>
>ENDDEFINE
>
>DEFINE CLASS another AS form
>	Top = 10
>	Left = 400
>	Caption = "Form with a control"
>
>	ADD OBJECT text1 AS textbox WITH ;
>		Left = 119, ;
>		Top = 14
>
>	ADD OBJECT label1 AS label WITH ;
>		AutoSize = .T., ;
>		Caption = "Click on this text", ;
>		Left = 18, ;
>		Top = 19
>
>ENDDEFINE
>
>
>User operations:
>
>0. Run This
>1. click on "Form with valid check"
>2. click on Top Textbox ( this is checked by the valid )
>3. write "pippo"
>4. click on TextBox bottom
>*** "pippo" is written on ControlSource
>*** Valid stop the lose focus
>5. click on "Form with control" title or formArea ( no textbox )
>*** Valid stop the lose focus, but events sequence is incorrect for me
>--> valid_violation.textbox.valid
>--> valid_violation.Deactivate  !!!!! why : the form is not deactivated
>--> valid_violation.Activate    !!!!! this is a patch
>--> otherForm.clickForm.MouseUp
>--> otherForm.clickForm.Click
>6. click on "Form with control" on the textBox
>*** VALID NOT STOP THE LOSE FOCUS
>--> valid_violation.textbox.Valid
>--> valid_violation.Deactivate
>--> valid_violation.Activate
>*** Now sequence continue !!!!!!
>--> otherForm.textbox.When
>--> valid_violation.textbox.LostFocus
>--> valid_violation.LostFocus
>--> valid_violation.Deactivate
>--> otherForm.Activate
>--> otherForm.GotFocus
>--> otherForm.textbox.GotFocus
>
>7. now click on "Form with valid check" on TextBox bottom
>*** you go on another control of the invalid form
>*** click on X window buton for close the invalid form
>
>
>Then the Valid() return .F. it is useless.
>
>Fabio
Mark McCasland
Midlothian, TX USA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform