How show action item to context menu, but not tollbar?

Answered

Hi,

I have action

public class MyAction extends FileChooserAction { /*...*/ }

and programmaticaly registration

DefaultActionGroup group = (DefaultActionGroup) actionManager.getAction("FileChooserToolbar");
group.add(new MyAction());

My custom action buttons add to toolbar modal dialog window and to context menu on right click mouse. How can I show buttons only in context menu or only toolbar?

Thanks

3 comments
Comment actions Permalink

You can check `AnActionEvent#isFromActionToolbar` and `AnActionEvent#isFromContextMenu`. (and `AnActionEvent#getPlace` to differentiate between different toolbars)

0
Avatar
Vassiliy Kudryashov
Comment actions Permalink

Aleksey means you should add some checks in update() method to update enabled/visible flags in presentation of AnActionEvent

0

Please sign in to leave a comment.