How do I listen for editor focus events?


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/ 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.

Object multicaster = EditorFactory.getInstance().getEventMulticaster();
if (multicaster instanceof EditorEventMulticasterEx) {
EditorEventMulticasterEx ex = (EditorEventMulticasterEx)multicaster;
ex.addFocusChangeListener(new FocusChangeListener() {

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


Please sign in to leave a comment.