Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Button click after textbox valid doesn't fire?
Message
From
04/12/2005 21:23:20
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01074348
Message ID:
01074807
Views:
18
I'm having a bit of trouble following something here. You call the chkTxtBox() function from the valid of the text box (call it TextA). If everything is ok, you set the txtOk property to True. If the textbox loses focus to some other control (say TextB) then the button when the button is now clicked from TextB, it registers that the txtOk property is True and thinks it's been clicked directly from TextA.

At what point do you set the property to False?

I don't really think this belongs at the control class level since it's such a one-off type of situation, so it still sounds like I have to put code in the gotfocus event of every control on the form to set the property to .F. unless I'm missing something obvious.


>Here is, simplified, what I did :
>- form property txtOk set to .F.
>- form method chkTxtBox to validate the textbox value:
>
thisform.txtOk = .F.
>do case
>case (invalid value)
>  return .F.
>case (valid but want a message)
>  messagebox()   && or if messagebox() for user input
>  thisform.txtOk = .T.
>  return .T.
>otherwise
>  return .T.
>endcase
>- in the textbox lostfocus
>
>if not thisform.chkTxtBox()
>  nodefault   && stay here
>endif
>
>- in the command button got focus
>
>if thisform.txtOk  && coming from the textbox
>  keyboard '{enter}'
>endif
>thisform.txtOk = .F.  && reset coming from the textbox
>
>My real case was a bit more complicated because if the button clicked was Cancel I didn't want any message.
>
>>This is the way I'll have to go. I'll have to create a new property and save the name of the active control into it. I'll probably to that from each control's gotfocus. Then in the gotfocus of the button I'll check if the last control was the textbox. If so, I'll run the button's click. Then set the last control property to the button.
>>
>>I don't suppose you know a simpler way to handle figuring out where the button click came from? If you do, I'm open to it.
>>
>>Thanks Doru.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform