Adobe Flex 3 Help

Specifying menu item mnemonics

A menu item mnemonic is a key associated with a menu item which, when pressed while the menu is displayed, is equivalent to selecting that menu item with the mouse. Typically, the operating system indicates a menu item's mnemonic by underlining that character in the name of the menu item. Mnemonics for menu items are supported in Windows. In Mac OS X, when a menu is activated a user types the first letter or letters of a menu item's label, then presses return to select the item. For more details about the behavior of mnemonics, see "Mnemonics" on page 6.

The simplest way to specify a mnemonic for a menu item in a FlexNativeMenu component is to include an underscore character ("_") in the menu item's label field, immediately to the left of the letter that serves as the mnemonic for that menu item. For instance, if the following XML node is used in a data provider for a FlexNativeMenu, the mnemonic for the command is the first character of the second word (the letter "A"):

<menuitem label="Save _As"/>

When the native menu is created, the underscore character is not included in the label. Instead, the character following the underscore becomes the mnemonic for the menu item. To include a literal underscore character in a menu item's name, use two underscore characters ("__"). This sequence is converted to one underscore in the menu item label.

As an alternative to using underscore characters in label names, you can provide an integer index position for the mnemonic character in a mnemonicIndex field in the data provider objects. You can also use another Object property or XML attribute by setting the FlexNativeMenu component's mnemonicIndexField property. To use complex logic for assigning mnemonics, you can specify a function for the FlexNativeMenu component's mnemonicIndexFunction property. Each of these properties provides a mechanism to define an integer (zero-based) index position for the menu items' mnemonics.