How would I go about making a keystone with multiple modifier masks? With the lack of explicitly specifying the command mask, Apple recommends this, for getting the mask:
Toolkit.getDefaultToolkit().getMenuShortcutMask();
In an example:
KeyStroke.getKeyStroke(KeyEvent.VK_N, Toolkit.getDefaultToolkit().getMenuShortcutMask();
On OS X, This would allow me to use this accelerator: Cmd+N/ ⌘N. It shows on the menu bar too:
However, what if I need to combine modifier masks? Like so: Cmd+Option+N/⌘⌥N. I've tried this:
KeyStroke.getKeyStroke("command option n");
But it doesn't do it. java.awt.Toolkit
doesn't seem to give me this option. So how can I add multiple masks to set as the accelerator?
The toolkit's
getMenuShortcutKeyMask()
returnsInputEvent.META_MASK
on Mac OS X. You can addInputEvent.ALT_MASK
to that to get ⌥⌘N.Starting with this example produces the result pictured: