How to detect MouseDown outside the EditorWindow

I’m adding a rename feature to my custom EditorWindow, so if the mouse is clicked, I need to unrename. And I tried use:

if (Event.current.type == EventType.MouseDown)
    Unrename();

But once the mouse is outside the editor window, it doesn’t work.

You don’t get mouse events if you click outside the editor window. Events are always only send to one target only. Since you click outside it means you clicked on another editor window. That means your editor window has to loose the focus. So you can use OnLostFocus.

2 Likes