Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: KeyStroke and JMenu



> I discovered that if you use "KeyEvent.VK_HELP" in Swing Menus that
> you get a fairly pleasant character showing a "?" in a circle (on the
> Macintosh OS X 10.4, Java 1.4.2).

To show the question mark in the menu is not the problem.
 
> Of course, this key is not the same as a "?" but I'm sure it would be
> possible to add a KeyListener to listen for "?"s being typed with the
> menuShortcutKeyMask pressed.

I think it's time for some code here. :)

The following line displays a question mark in the menu, but without the
menu shortcut. The action event is fired if yout type a "?".
    helpItem.setAccelerator(KeyStroke.getKeyStroke(new Character('?'), 0));
 
If you try to add the menu shortcut key mask the menu item is displayed
properly, but the action event isn't fired any more (with German keyboard):
    helpItem.setAccelerator(KeyStroke.getKeyStroke(new Character('?'),
                     Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

Manuel


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden

References: 
 >Re: KeyStroke and JMenu (From: Ian Cheyne <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.