Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to apply ON KEY LABEL
Message
 
To
12/03/2002 04:43:09
Hee Lim Wang
Fantasy Software Enterprise
Malaysia
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00631371
Message ID:
00631428
Views:
25
>I applied ON KEY LABEL F2 thisform.edit.click during INI in my form
>but error when I press F2 button
>so how to use function key to click my Edit Button instead of using mouse ?

Hee Lim,

In addition to what Vlad has told you. ON KEY LABEL is an intercommand interrupt, that is it will interrupt running code. This means if a method in your form is running and the user presses F2 the code will interrupted while the button's click is run. This is usually not a desired behavior.

There are other ways to run your code with a key press. One is to define a menu with an option that calls the code you want and then assign the key you want as the shortcut key for that menu option.

Another issue about your example, it is usually not a good idea to call and event (like Thisform.Button.Click()). Events are ment to run when something happens. Instead you should put the code with the behavior in a method, then in your button's click call that method. You can then easily call that method anywhere else you like as well. You might ask why is this the case, well one reason is that in your example if you later remove that button pressing F2 will error. This means that if you do anything to that button you must also worry about all the places you called its events.

You can read a lot more about good OOP practises at http://fox.wikis.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform