From ebf3999cfe2685e3192de31f7b2b0c36587ca8b3 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Wed, 16 Apr 2025 20:57:12 +0300 Subject: [PATCH] Fix rubber band selector activating outside of the viewport This usually happens while trying to drag the window from window handle --- Source/Editor/Viewport/EditorViewport.cs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index 13af558d2..9abb631bb 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -1570,13 +1570,10 @@ namespace FlaxEditor.Viewport // Get parent window var win = (WindowRootControl)Root; - - // Get current mouse position in the view + if (win.IsFocused) { - // When the window is not focused, the position in window does not return sane values - Float2 pos = PointFromWindow(win.MousePosition); - if (!float.IsInfinity(pos.LengthSquared)) - _viewMousePos = pos; + // Get current mouse position in the view + _viewMousePos = PointFromWindow(win.MousePosition); } // Update input @@ -1594,8 +1591,8 @@ namespace FlaxEditor.Viewport EndMouseCapture(); } #if PLATFORM_SDL - bool useMouse = IsControllingMouse || true; _prevInput = _input; + bool useMouse = IsControllingMouse || ContainsPoint(ref _viewMousePos) || _prevInput.IsControllingMouse; if (canUseInput && ContainsFocus) _input.Gather(win.Window, useMouse, ref _prevInput); else