13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Working with m<strong>en</strong>us<br />

This example assigns Ctrl+Shift+G as the key equival<strong>en</strong>t by setting the modifier array directly:<br />

var item:NativeM<strong>en</strong>uItem = new NativeM<strong>en</strong>uItem("Ungroup");<br />

item.keyEquival<strong>en</strong>t = "G";<br />

item.keyEquival<strong>en</strong>tModifiers = [Keyboard.CONTROL];<br />

Note: Key equival<strong>en</strong>ts are only triggered for application and window m<strong>en</strong>us. If you add a key equival<strong>en</strong>t to a context or<br />

pop-up m<strong>en</strong>u, the key equival<strong>en</strong>t is displayed in the m<strong>en</strong>u label, but the associated m<strong>en</strong>u command is never invoked.<br />

Mnemonics (AIR)<br />

Adobe AIR 1.0 and later<br />

Mnemonics are part of the operating system keyboard interface to m<strong>en</strong>us. Linux, Mac OS X, and Windows allow users<br />

to op<strong>en</strong> m<strong>en</strong>us and select commands with the keyboard, but there are subtle differ<strong>en</strong>ces.<br />

On Mac OS X, the user types the first letter or two of the m<strong>en</strong>u or command and th<strong>en</strong> presses the return key. The<br />

mnemonicIndex property is ignored.<br />

On Windows, only a single letter is significant. By default, the significant letter is the first character in the label, but if<br />

you assign a mnemonic to the m<strong>en</strong>u item, th<strong>en</strong> the significant character becomes the designated letter. If two items in<br />

a m<strong>en</strong>u have the same significant character (whether or not a mnemonic has be<strong>en</strong> assigned), th<strong>en</strong> the user’s keyboard<br />

interaction with the m<strong>en</strong>u changes slightly. Instead of pressing a single letter to select the m<strong>en</strong>u or command, the user<br />

must press the letter as many times as necessary to highlight the desired item and th<strong>en</strong> press the <strong>en</strong>ter key to complete<br />

the selection. To maintain a consist<strong>en</strong>t behavior, you should assign a unique mnemonic to each item in a m<strong>en</strong>u for<br />

window m<strong>en</strong>us.<br />

On Linux, no default mnemonic is provided. You must specify a value for the mnemonicIndex property of a m<strong>en</strong>u item<br />

to provide a mnemonic.<br />

Specify the mnemonic character as an index into the label string. The index of the first character in a label is 0. Thus,<br />

to use “r” as the mnemonic for a m<strong>en</strong>u item labeled, “Format,” you would set the mnemonicIndex property equal to 2.<br />

var item:NativeM<strong>en</strong>uItem = new NativeM<strong>en</strong>uItem("Format");<br />

item.mnemonicIndex = 2;<br />

M<strong>en</strong>u item state<br />

Adobe AIR 1.0 and later<br />

M<strong>en</strong>u items have the two state properties, checked and <strong>en</strong>abled:<br />

checked Set to true to display a check mark next to the item label.<br />

var item:NativeM<strong>en</strong>uItem = new NativeM<strong>en</strong>uItem("Format");<br />

item.checked = true;<br />

<strong>en</strong>abled Toggle the value betwe<strong>en</strong> true and false to control whether the command is <strong>en</strong>abled. Disabled items are<br />

visually “grayed-out” and do not dispatch select ev<strong>en</strong>ts.<br />

var item:NativeM<strong>en</strong>uItem = new NativeM<strong>en</strong>uItem("Format");<br />

item.<strong>en</strong>abled = false;<br />

Last updated 6/6/2012<br />

637

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!