Mnemonics provide another mechanism for using the keyboard to manipulate action bars (and dialog boxes, see Dialog Boxes, Dialog Regions, and Controls). The Alt key, pressed alone, or in conjunction with the mnemonic key, begins the keyboard input. If Alt is pressed and released, the user can use the arrow keys to move among the pull-downs in the action bar (and the system menu, if it is present). (You can also use the F10 key instead of the Alt key.)
Each time the left or right arrow key is pressed, the text of the next pull-down is highlighted to indicate that it is currently selected. The user can then press the Enter key to pull down the currently selected pull-down or system menu.
The arrow keys can be used to move the among the choices in the pull-down. The highlight indicates the current choice. Pressing the Enter key selects the current choice. Pressing the Esc key returns the pull-down to the action bar. Pressing the Esc key again exits keyboard mode.
While in keyboard mode, individual choices, buttons, and pull-downs can also be selected using their mnemonics characters. If the text of an item contains a tilde (~), the character immediately following the tilde becomes the mnemonic character for that item. The mnemonic character is indicated to the user by being underlined in the item's text. Pressing the mnemonic key while in keyboard mode causes a choice or button to be selected, or a pull-down to be made visible. Note that the tilde can also be used to create mnemonic characters in the action bar.
The first letter of each pull-down and choice functions as the default mnemonic. If more than one item has the same default mnemonic character, hold down the Alt key and repeatedly press the letter to toggle among the choices with the same character. The mnemonic character specified with the tilde has precedence over the default mnemonic characters.
In the File pull-down, the line under the "O" in the Open File choice indicates that "O" is the mnemonic character for that choice. Notice that because both the Save File and Save As choices begin with "S", the developer chose "A" as the mnemonic character for the Save As choice. You are responsible for making each mnemonic character unique when designing the pull-down.
The following is the definition of the File pull-down.
pulldown FileMenu text "~File" # This pulldown will be
# 2 columns.
item OpenFile # Item reference to a
# predefined choice.
choice NewFile text "~New File...\tF5"
accelerator is KEY_F5
choice SaveFile text "~Save\tF6"
accelerator is KEY_F6
choice SaveAs text "Save ~As...\tAlt+F6"
accelerator is alt KEY_F6
end pulldown
Mnemonics can be used before or after an Alt key is released. For instance, the user can select File Save in one of several ways (assuming the pull-down exists in the action bar):
Press and release Alt
Press F
Press S
Press and hold Alt
Press F
Release Alt
Press S
Press and hold Alt
Press F
Press S
Release Alt