How to bind action to an UI element?

I am developing an Intellij IDEA plugin. Here [1] is explained how to bind an action to menu item or toolbar button.

But is it possible to bind an action to some UI element, folding \+, for example?
Or even create an icon in the gutter area [2] and bind an action to it?

It is much better for user experience but I didn't find how to do it in JetBrain's resources.


Comment actions Permalink

It would be good to see your use case in order to provide a better answer; However -
- You can give a line marker provider with
- You can use the `create action` action within a folder's context menu to create a new action, this will open a nice UI with the list of possible GROUP_IDs you can choose from, you can also view the IdeActions class to view the list of constants - I believe for a custom UI component you should implement CustomComponentAction

Edit - I am not sure if the Line Marker Provider I suggested matches your use case, however there's a lot of code you can check out for that.
Perhaps check out com.intellij.openapi.editor.markup.GutterIconRenderer, and GutterActionRenderer,

Comment actions Permalink

My use case is about macros. I want to have some sign (default or custom, folding '+' is probably the best) on a line of macro usage. And after pressing this sign, show expansion of the macro.

Line Marker Provider (LMP) could work. But how do I bind an action to an LMP? Is it possible?

> You can use the `create action` action within a folder's context menu
I've already used that but it allows to create actions only for a menu item or a toolbar button. I didn't find any GROUP_IDs of folding '+' sign or red breakpoint sign. And for usability it is much better not to go to a menu (if it is feasible, of course).

Comment actions Permalink

Your use case seems very similiar to code folding -
Would that be useful?


Please sign in to leave a comment.