Share via


Assigning Tasks to a Menu System

As you create a menu system, you should consider ease of access to the system, and you must assign tasks to the system. You must give menus and menu items tasks to perform, such as displaying forms, toolbars, and other menu systems. You should define access keys to permit entry to the menu system. You can also add keyboard shortcuts and enable or disable menu items for more control.

Assigning Access Keys

Well-designed menus have access keys for quick keyboard access to the menu functionality. The access key is represented by the underlined letter in the menu title or menu item. For instance, the Visual FoxPro File menu uses "F" as its access key.

If you don't assign an access key to a menu title or menu item, Visual FoxPro automatically assigns the first letter as the access key. For example, the Customer menu created previously didn't have a defined access key. Accordingly, Visual FoxPro assigned the first letter (C) as the access key.

To specify the access key for a menu or menu item

  • Type \< to the left of the letter you want as the access key.

    For example, to set the access key to "u" in the Customer menu title, replace Customer with C\<ustomer in the Prompt column.

    Note   If an access key for your menu system doesn't work, look for duplicate access keys.

Assigning Keyboard Shortcuts

In addition to assigning access keys, you can specify keyboard shortcuts for menus or menu items. As with access keys, keyboard shortcuts let you choose a menu or menu item by holding down one key while pressing another. The difference between access keys and keyboard shortcuts is that you can use a keyboard shortcut to choose a menu item without first displaying its menu.

Keyboard shortcuts for Visual FoxPro menu items are combinations of the CTRL or ALT key and another key. For instance, you can create a new file in Visual FoxPro by pressing CTRL+N.

To specify a keyboard shortcut for a menu or menu item

  1. In the Prompt column, select the appropriate menu title or menu item.

  2. Choose the button in the Options column to display the Prompt Options dialog box.

  3. In the Key Label box, press a key combination to create a keyboard shortcut.

    If a menu item doesn't have a keyboard shortcut, Visual FoxPro displays "(press the key)" in the Key Label box.

  4. In the Key Text box, add the text you want to appear beside the menu item.

    By default, Visual FoxPro repeats the keyboard shortcut from the Key Label box in the Key Text box. However, you can change the text in the Key Text box if you want your application to display different text. For example, if both the Key Label and Key Text were CTRL+R, you could change the Key Text value to ^R.

    Note   CTRL+J is an invalid keyboard shortcut because it is used to close certain dialog boxes in Visual FoxPro.

See Also

Including Menus in an Application | Enabling and Disabling Menu Items | Creating Menus, Shortcut Menus, Menu Items, and Submenus, | Designing Menus and Toolbars | Compiling an Application