Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do you get a textbox to keep the focus ?
Message
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00068247
Message ID:
00068271
Views:
15
>>>>>I have a textbox that is used to enter a search string.
>>>>>After the search string text has been entered, and the enter button is pressed, the focus moves to the next object on the form.
>>>>>How do I get this textbox to "keep the focus" after the enter key is pressed, so that another search string can be entered. ?
>>>>>(What exactly do I type, and where do I place this code? )
>>>>>
>>>>>Your help would be greatly appreciated.
>>>>
>>>>You can try putting RETURN .F. in the VALID Event of the TextBox
>>>
>>>Thanks, I have tried this and it solves the problem.
>>>Now the only problem is that when I do decide to leave the textbox by clicking somewhere else on the form, I get a wait window message "Invalid Input". Any ideas on this ? (Thanks, I'm new to VFP)
>>
>>try RETURN 0 (zero). I would do the following:
>>if lastkey()=13 && test for the ENTER key being hit
>> return 0
>>endif
>
>also, because the valid now tests for lastkey(), lastkey() will always be 13 until another KEYSTROKE. Mouse clicks do not reset this. So clicking on another object (close button, command button, etc.) will not work until you hit some other key like the tab, one of the arrow keys, etc. Focus will remain in the textbox until you do so. You could use a KEYBOARD command before the RETURN 0 above, but it would have to be something that would not shift focus from the textbox.

I have tried using your above code in the Valid method, and it works perfectly. I have no trouble leaving the textbox either, and can click or tab out of it without any problem.

Thanks for your help.
David Wheeldon
Previous
Reply
Map
View

Click here to load this message in the networking platform