Menu Accelerators

To enter an Accelerator item, keyboard focus should be given to the Accelerator Keys control, then the appropriate key combination pressed, such as CTRL+S, etc. Once the right accelerator is visible in the control, press the Enter key. This accepts the selection and automatically moves the selection to the next item in the Structure Diagram box, while keyboard focus will stay with the Accelerator Keys control. In this way, the accelerators can be quickly entered for all menu items, just by pressing Enter after each accelerator is entered.

Likewise, the same process can be repeated with the Prompt field. All prompt strings defined for menu items will be saved as a String Table in a resource file ( .RC file) created by PowerBASIC Forms (along with the VERSIONINFO block, etc).

Prompt strings are usually used to convey helpful descriptions of highlighted menu items. A typical prompt string might describe the operation of a menu item, or how the user can enable or disable the menu item, etc.

For dialogs that contain both a status bar control and a menu, PowerBASIC Forms v1.50 (or later) will create and/or insert code for a %WM_MENUSELECT callback handler that will automatically display prompt strings in the status bar as menu items are highlighted by the user.

It should be noted that accelerators may only be created for Menu Items, and that ALT key combinations are not allowed unless combined with CTRL or SHIFT keys. This is because all ALT key combinations are reserved by the operating system for menu and control hot-keys and should not be used by applications as accelerators.

However, it is possible to get PowerBASIC Forms to display a system key combination in a Menu Item. This is achieved by appending the accelerator definition to the caption of the Menu Item by adding "\t" followed by the key combination.

For Example, ALT+F4 is the system key combination for exiting a program, but to show this as the accelerator of a Menu Item, set the Caption of the Menu Item to show "E&xit\tAlt+F4". This produces a Menu Item that shows "Exit Alt+F4".

The "\t" in the Caption represents a tab character, which causes the text that follows it to be displayed on the far right edge of the menu member's Caption at run-time. When generating the PowerBASIC code, PowerBASIC Forms automatically builds the accelerator table to suit the accelerators defined, whether they are specified with the "\t" prefix, or are entered in the Accelerator Keys control.

When a saved PowerBASIC Forms file is reopened by PowerBASIC Forms, the accelerators previously defined in the Accelerator Keys field will have been translated into the "\t" format and appear in the menu member's caption. This is an intentional design behavior intended to allow the programmer to quickly override the automatic accelerator key text. That is, the accelerator for a given menu member can be edited in the Caption field. Care should be taken to use the standard format for such editing, using combinations of the "Alt", "Ctrl", and "Shift" keywords. For example, "Cu&t\tCtrl+DEL" and "Cu&t\tCtrl+Alt+Shift+F1" are valid accelerator definitions in the Caption field.

If no accelerator is required, omit the text from the "\t" position, or leave the text blank after the "\t" code. If a "manually" defined accelerator is entered into the Caption field, and an accelerator is created in the Accelerator Keys field, then only the accelerator definition in the Caption field is retained (the Accelerator Keys field definition is dropped when the file is saved).

The (Del) key is a special key that is used by the Accelerator Key field to clear the contents of the field. Pressing that key as an Accelerator Key shows "Num Del" in the Accelerator Key field, but "Del" is what will appear in the final menu at run-time, and the Del key will activate the desired action at run-time. That is, PowerBASIC Forms uses "Num Del" for the purposes of display only. To delete an accelerator combination in the Accelerator Keys field, press the Backspace or Space keys.



The ampersand (&) character in a Caption of a menu member makes the character that follows it into a mnemonic or hot-key. This means the nominated key can be pressed to activate that menu member when the drop-down menu is displayed, or if the menu member is a top-level item, by pressing ALT+letter. For example, in the caption text "E&xit", the letter "x" is the hot-key for the menu member.

To include an ampersand in a caption, use two ampersands.



Finally, it should be noted that PowerBASIC Forms requires that a menu must begin with and contain at least one Pop-up menu member.

To delete a menu from the project, or assign an existing menu to another dialog, use the Select Dialog box.


See Also

Menu Editor

Creating a menu

Menu accelerators

Menu Tutorial

Version Info Editor

ID Editor

Tab Order Editor

Selecting/linking dialogs and menus

Test mode