Reputation: 1075
How to add a caret listener to the active editor during "on load", such as when the intellij application starts or when an editor is opened?
I know how to do so in actionPerformed but apparently it is not the right place to do so, and the constructor has no AnActionEvent being passed in so I couldn't get an Editor instance.
Upvotes: 0
Views: 410
Reputation: 86
I'm not sure what you mean by 'active' editor here. Editor which is active when a particular action is invoked can be retrieved from DataContext passed to actionPerformed. If you want to add a listener to any editor, when it's created, you can do it in EditorFactoryListener.editorCreated. It can be also simpler to register a listener which will get events from all editors (see EditorFactory.getEventMulticaster()).
Upvotes: 1