Next: , Previous: , Up: Menu Accelerators   [Contents][Index]


27.7.1 Creating Menu Accelerators

Menu accelerators are specified as part of the menubar format using the :accelerator tag to specify a key or by placing "%_" in the menu or menu item name prior to the letter which is to be used as the accelerator key. The advantage of the second method is that the menu rendering code then knows to draw an underline under that character, which is the canonical way of indicating an accelerator key to a user.

For example, the command

(add-submenu nil '("%_Test"
                   ["One" (insert "1") :accelerator ?1 :active t]
                   ["%_Two" (insert "2")]
                   ["%_3" (insert "3")]))

will add a new menu to the top level menubar. The new menu can be reached by pressing "t" while the top level menubar is active. When the menu is active, pressing "1" will activate the first item and insert the character "1" into the buffer. Pressing "2" will activate the second item and insert the character "2" into the buffer. Pressing "3" will activate the third item and insert the character "3" into the buffer.

It is possible to activate the top level menubar itself using accelerator keys. See Menu Accelerator Functions.