How do I listen for editor focus events?

Answered

I'm building a tool window that shows the tests for a given source file and I want it to update as I focus on a different open source file just like the Structure pane updates upon focus to a different open source file.

I've tried similar to:

intellij-community/DaemonListeners.java at master · JetBrains/intellij-community · GitHub

But I can't get that to actually work.  Any ideas?  I tried digging through the IntelliJ Community source but couldn't find it.

2 comments
Comment actions Permalink
Object multicaster = EditorFactory.getInstance().getEventMulticaster();
if (multicaster instanceof EditorEventMulticasterEx) {
EditorEventMulticasterEx ex = (EditorEventMulticasterEx)multicaster;
ex.addFocusChangeListener(new FocusChangeListener() {
....
}
1
Comment actions Permalink

Thank you Yann Cebron, that works for a local IDE, but it does not seem to work in the remote IDE via JB Gateway.

0

Please sign in to leave a comment.