Update icons on toolbar when menu option selected

已回答

I am developing a plugin in which I'll have an action as menu option and the action on the toolbar. Like the debug icon in IntelliJ, I'd like to show a small green dot when it's active and remove the green dot when it is not active. I achieved that using a simple e.getPresentation().setIcon() and changing icons when ever the toolbar icon is clicked.

Problem is I am unable to find a way to update the toolbar icon when the user would click on menu option. Can you help me do this ?

0
   * If the action is added to a toolbar, its "update" can be called twice a second, but only if there was
* any user activity or a focus transfer. If your action's availability is changed
* in absence of any of these events, please call {@code ActivityTracker.getInstance().inc()} to notify
* action subsystem to update all toolbar actions when your subsystem's determines that its actions' visibility might be affected.

https://github.com/JetBrains/intellij-community/blob/master/platform/editor-ui-api/src/com/intellij/openapi/actionSystem/AnAction.java#L267

1

请先登录再写评论。