Find shortcut of certain action
已回答
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
请先登录再写评论。
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?
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.
Thanks for clarifying.
I suggest trying to use
AnAction.copyShortcutFrom(actionManager.getAction("RenameElement")).It can be done in
com.intellij.openapi.actionSystem.impl.ActionConfigurationCustomizerorcom.intellij.openapi.actionSystem.impl.DynamicActionConfigurationCustomizer.Use
com.intellij.openapi.actionSystem.ActionPromoterto promote your action for the same shortcut when your tool window is active.Thanks. I am going to look into it.