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

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

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

请先登录再写评论。