Inconsistent behavior rewriting shortcuts for Mac OS

According to this post, IntelliJ IDEA remaps plugin shortcuts containing [Ctrl] for Mac OS and Mac OS X to [⌘]. However the behavior of this remapping is inconsistent. For example, if the shortcuts are configured like this:

<action id="SomeAction"...>
<keyboard-shortcut keymap="Mac OS X" first-keystroke="ctrl SEMICOLON"/>
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="ctrl SEMICOLON"/>
<keyboard-shortcut keymap="$default" first-keystroke="ctrl SEMICOLON"/>
</action>

it does not perform remapping. However if the default keymap is declared first, it does perform remapping, adding a new primary shortcut which has priority over any subsequent keyboard shortcut declarations:

<action id="SomeAction"...>
<keyboard-shortcut keymap="$default" first-keystroke="ctrl SEMICOLON"/>
<keyboard-shortcut keymap="Mac OS X" first-keystroke="ctrl SEMICOLON"/>
<keyboard-shortcut keymap="Mac OS X 10.5+" first-keystroke="ctrl SEMICOLON"/>
</action>

This behavior is problematic, because it does not appear to be possible to fetch multiple mappings from the API:

ActionManager.getInstance().getKeyboardShortcut("SomeAction") // Only returns the primary keystroke!

Since the only way to avoid remapping on Mac OS appears to be to reordering the keyboard shortcut declarations in the XML, this is what I have done, but it seems fairly unintuitive. Is there a better way to avoid remapping, or read all assigned KeyStrokes for an Action?

0
Avatar
Permanently deleted user

Here is a solution for fetching multiple shortcuts, in case someone else runs into the same issue:

    AnAction action = ActionManager.getInstance().getAction(actionId);
    final ShortcutSet shortcutSet = action.getShortcutSet();
    final Shortcut[] shortcuts = shortcutSet.getShortcuts();
0

请先登录再写评论。