Registering some transient/temporary keyboard shortcuts

Answered

I have an EditorActionHandler which basically implements search in the current editor. I would like to register some "temporary" keyboard shortcuts (such as for example ctrl-w) that are only available when the search is active, and then gone again when the search is over.

In other words, I do not want to modify the main active keyboard layout, but only register a few additional keyboard shortcuts that are activated during the search.

How would I best go about doing this? I have tried using variants of "action.registerCustomShortcutSet(...)" on the editor component, but this doesn't seem to block the existing actions for the keyboard shortcuts.

1 comment
Comment actions Permalink

Hi Jesper,

Using AnAction.registerCustomShortcutSet() seems fine. When multiple actions are assigned to the same shortcut, then the preferred one can be promoted with:

  • com.intellij.openapi.actionSystem.ActionPromoter

I suggest promoting your action when your custom search is active.

0

Please sign in to leave a comment.