Listen to event for editor focus / unfocus.
MessageBus bus = project.getMessageBus();
MessageBusConnection connection = bus.connect();
connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
@Override
public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
System.out.println("11111111111111111111111111");
}
@Override
public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
System.out.println("222222222222222222222222222");
}
});
This will only be triggered when something is opened, not when it is activated / unactivated.
Is there a way to listen to desired events?
Please sign in to leave a comment.
I had to poll in the end.
It looks like to me, that FileEditorManagerListener.selectionChanged is triggered when the current file is in focus.