Find shortcut of certain action

Answered

I am developing a plugin and want to implement a rename action for certain elements in the plugin. Ideally I want to re-use the rename shortcut which is configured in the keymap. Is there a way to obtain this shortcut programatically?

Regards,

Jamie

0
4 comments

Hi Jamie,

I don't understand why you want to reuse the existing shortcut. How your action differs from the regular rename action? In what context your action will be executed? Could you please describe your use case in more detail?

0

Sure!

My plugin implement a custom toolwindow which contains a list of items. The user is able to delete or rename those items (a JBList component). To rename an item the user can right-click and use the Rename action in the context menu. I also want to provide a shortcut to rename an item.

Instead of using a new shortcut, I think it will be helpful to the user if the user can just use the existing rename shortcut when the list has focus. That way, the user does not need to remember another shortcut to rename items in the list.

Hope this clarifies the intention.

0

Thanks for clarifying.

I suggest trying to use AnAction.copyShortcutFrom(actionManager.getAction("RenameElement")).

It can be done in com.intellij.openapi.actionSystem.impl.ActionConfigurationCustomizer or com.intellij.openapi.actionSystem.impl.DynamicActionConfigurationCustomizer.

Use com.intellij.openapi.actionSystem.ActionPromoter to promote your action for the same shortcut when your tool window is active.

0

Thanks. I am going to look into it.

0

Please sign in to leave a comment.