xuyca


I know that we can assign a hotkey 'S' for a button like :
thisform.button1.caption="\<Start"
The question is: how to assign a hot key "Page Up" or "F2" key for the button in a form




Re: Hot key question

Ronald Ricardo Ramirez Moran


You can'nt make it using a "Hot Key" assignament, instead, you need enable the KeyPreview property in your form, and to provide custom code into the KeyPress Method with the handlement of your keys. A Example:

** More at
**** http://fox.wikis.com/wc.dll Wiki~KeyPress~VFP
**** http://msdn2.microsoft.com/en-us/library/6wd37f7s(VS.80).aspx
Procedure KeyPress (nKeyCode, nShiftAltCtrl)

** nKeycode returns a inkey value. http://msdn2.microsoft.com/en-us/library/aa977875(VS.80).aspx

Do Case
Case nKeyCode = -1 && Handles "F2" key.
Thisform.Button1.Click()

Case nKeyCode = -2 && Handles "F3" key.
Thisform.Button2.Click

EndCase

EndProc

Regards,







Re: Hot key question

xuyca

Thanks a lot. I did like that before too. But it have to add too much code in keypress. I just want to know there are any other method to assign a hot key for the controls.






Re: Hot key question

dni

You may use inkey() in one of methods of button.




Re: Hot key question

Craig Berntson

Can you add it to a menu option




Re: Hot key question

xuyca

No menu in my form. I just want to get a easy way to add code in button class.





Re: Hot key question

dni

You may insert lastkey() or inkey() in a valid method (if lastkey()....)




Re: Hot key question

Tamar E. Granor

A menu doesn't have to be visible to be available. You can define a menu popup and never display it and still have the menu shortcuts available to the users.

Tamar