Use Cmd instead of Ctrl on Mac (Swing)

H

Hendrik Maryns

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Although modern Macs do have a Ctrl key now, it is custom to use the Cmd
key for keyboard shortcuts. My Swing app contains a lot of actions that
have the following:

openAction.putValue(Action.NAME, "Open…");
openAction.putValue(Action.ACCELERATOR_KEY,
KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_DOWN_MASK));
openAction.putValue(Action.MNEMONIC_KEY, KeyEvent.VK_O);

and then are registered in a menu. This makes the accelerator key
available automatically, as well as centralizing all information about
the menu.

Is there a general trick to tell Swing that when it is running on an
Apple, it should use Cmd for the accelerator key instead of Ctrl?

Cheers, H.
- --
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org

iEYEARECAAYFAkjuIBgACgkQBGFP0CTku6OUqgCdEyFp7BRPvl2F6tF6CF9qBOjn
pZwAoNRZys5lUWUtVGk1Wo70ltlOQL2c
=hoeh
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top