Hey list,
Do people here work with AIR? Or is there any better-aligned
mailing list?
Anyway. I'm using AIR 1.5's NativeMenuItem's .keyEquivalent and
.keyEquivalentModifier. That feature is pretty cool and works like
this:
var item:NativeMenuItem = new NativeMenuItem("Do Whatever");
item.keyEquivalent = "d";
item.keyEquivalentModifiers = [Keyboard.CONTROL];
Then when the user presses CTRL+D, the menu item is executed.
(More information at
http://livedocs.adobe.com/flex/3/html/help.html?
content=Menus_2.html)
I'm having a problem setting the .keyEquivalent, though. It accepts
strings, so you can't set them to things like Enter, Tab, Del, F1,
etc.
You can try doing this:
var item:NativeMenuItem = new NativeMenuItem("Do Whatever");
item.keyEquivalent = "F1";
item.keyEquivalentModifiers = [Keyboard.CONTROL];
And then, funny enough, the menu item will display "CTRL+F1" as the
shortcut; but it won't work. The actual shortcut will be CTRL+F -
that
is, it only takes the first character of the string as the
activation
key (!). The documentation seems to completely ignore the problem,
very briefly mentioning that .keyEquivalent accepts a string. In
fact,
you can write *anything* as the .keyEquivalent and it'll be shown
there on the menu, but only the first char matters.
I tried a lot of different things, like adding Keyboard.F1 to the
keyEquivalentModifiers array, using Keyboard.F1's key code as a
keyEquivalent char, using AIR's new .STRING_F1 or KEYNAME_F1
constants, and things like that. Nothing seems to work though.
Has somebody ran into that and found a solution that works? Or am I
imagining things? It seems odd to me that I'm able to create a
menu in
Flash which responds to F1 while I can't do that in AIR using its
(great) native menus. Of course I can always add the shortcuts as
some
keyboard event listener hidden somewhere, but it'd be less than
optimal (and wouldn't display the shortcut on the menu).
Thanks,
Zeh
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders