FIX: More Than One Keyboard Letter Will Activate Some Hot Keys

Last reviewed: December 5, 1997
Article ID: Q164372
The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b, 5.0

SYMPTOMS

When assigning hot keys to the command button, check box, or option button objects, some keys trigger that hot key besides the letter key that was assigned to it. When assigning the letters G, O, R, or S as hot keys, pressing the Insert, Delete, Home, or End keys also triggers the objects that these letters are assigned to. Also, using the hot key letters A, B, and C can be triggered by the F7, F8, and F9 keys.

RESOLUTION

To work around this problem, use the ON KEY LABEL command to turn off these keys. Be careful using this method since it might cause problems in some instances because the Insert, Delete, Home, or End keys may not be available for things like editing data. The syntax for this command is ON KEY LABEL <key name> *. Note that the asterisk is what disables the key. To turn the key back on, issue ON KEY LABEL <key name> without the asterisk. Look in the "Steps to Reproduce Behavior" section for examples of using this command in a form.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem has been fixed in Visual FoxPro 5.0a.

MORE INFORMATION

To allow an object to have hot key capability, place the "\<" symbols in front of the letter that is to be used as the hot key. For example, placing "\<Quit" in the Caption property of the object allows the pressing of the Q key to give focus to that object. Any letter in the caption can be assigned as the hot key. Another example would be "E\<xit", which allows the X key to become the hot key. No two objects on the form can have the same hot key letter. Whichever object was assigned the hot key letter first is the one that will receive focus.

Steps to Reproduce Behavior

  1. Create a form and add seven command buttons to it.

  2. In the Caption property of each command button add the following:

          Button 1:    \<GO TOP
          Button 2:    \<OFF
          Button 3:    \<RUN
          Button 4:    \<SAVE
          Button 5:    \<APPEND
          Button 6:    \<BROWSE
          Button 7:    \<CANCEL
    
    

  3. Run the form and press the Insert, Delete, Home, End, F7, F8, and F9 keys. Note that after pressing each key, the focus is set to the corresponding button.

  4. To fix the problem, close the form and add the following code to the Init event of the form:

          ON KEY LABEL INS *
          ON KEY LABEL DEL *
          ON KEY LABEL HOME *
          ON KEY LABEL END *
          ON KEY LABEL F7 *
          ON KEY LABEL F8 *
          ON KEY LABEL F9 *
    

  5. If you want to return the keys to their default functionality, add the following code to the Destroy event of the form:

          ON KEY LABEL INS
          ON KEY LABEL DEL
          ON KEY LABEL HOME
          ON KEY LABEL END
          ON KEY LABEL F7
          ON KEY LABEL F8
          ON KEY LABEL F9
    

REFERENCES

For information on a similar issue, please refer to the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q158830
   TITLE     : FIX: OptionGroup with M, P, H, K Hot Keys Fire Valid
Keywords          : buglist3.00 buglist3.00b buglist5.00 FxtoolFormdes vfoxwin vfpfix5.0a kbtool kbbuglist kbfixlist
Version           : 3.0 3.0b 5.0
Platform          : WINDOWS
Issue type        : kbbug
Solution Type     : kbfix


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: December 5, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.