From 969d0390cee7651a2799ae9df1880c33f515fb02 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 5 Feb 2024 09:27:28 +0100 Subject: [PATCH] Add auto focus to Editor Window when nothing clicked inside it --- Source/Editor/Windows/EditorWindow.cs | 37 +++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Source/Editor/Windows/EditorWindow.cs b/Source/Editor/Windows/EditorWindow.cs index ff0673c11..445287cab 100644 --- a/Source/Editor/Windows/EditorWindow.cs +++ b/Source/Editor/Windows/EditorWindow.cs @@ -14,6 +14,8 @@ namespace FlaxEditor.Windows /// public abstract class EditorWindow : DockWindow { + private bool _mouseDown; + /// /// Gets the editor object. /// @@ -223,6 +225,41 @@ namespace FlaxEditor.Windows return false; } + /// + public override bool OnMouseDown(Float2 location, MouseButton button) + { + if (base.OnMouseDown(location, button)) + return true; + if (button == MouseButton.Left) + { + _mouseDown = true; + return true; + } + return false; + } + + /// + public override bool OnMouseUp(Float2 location, MouseButton button) + { + if (base.OnMouseUp(location, button)) + return true; + if (button == MouseButton.Left && _mouseDown) + { + _mouseDown = false; + Focus(); + return true; + } + return false; + } + + /// + public override void OnMouseLeave() + { + _mouseDown = false; + + base.OnMouseLeave(); + } + /// public override void OnDestroy() {