From b7305edd0438ce4e23b5e57ab1a8e72135716a53 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 16:32:22 +0100 Subject: [PATCH] OrbitCamera: a second press during a drag is ignored, as Blender's modal operator ignores it A drag whose own button is no longer held (a lost release) still ends, so the next press starts a new one. Co-Authored-By: Claude Sonnet 5.5 --- client/OrbitCamera.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/client/OrbitCamera.cs b/client/OrbitCamera.cs index 24654f6..73b8c2e 100644 --- a/client/OrbitCamera.cs +++ b/client/OrbitCamera.cs @@ -77,7 +77,7 @@ public partial class OrbitCamera : Camera3D Distance = wheel.ButtonIndex == MouseButton.WheelUp ? _distance / MathF.Pow(ZoomStep, wheel.Factor) : _distance * MathF.Pow(ZoomStep, wheel.Factor); Handle(); break; - case InputEventMouseButton { Pressed: true } press: + case InputEventMouseButton { Pressed: true } press when _drag is null || StaleDrag(press.ButtonMask): foreach (var row in Bindings) { if (row.Button != press.ButtonIndex || row.Alt != press.AltPressed || row.Shift != press.ShiftPressed || row.Ctrl != press.CtrlPressed) continue; @@ -93,14 +93,22 @@ public partial class OrbitCamera : Camera3D Handle(); break; case InputEventMouseMotion motion when _drag is { } drag: - var held = drag.Button == MouseButton.Left ? MouseButtonMask.Left : MouseButtonMask.Middle; - if ((motion.ButtonMask & held) == 0) { _drag = null; return; } // the release was lost, to a focus change say + if ((motion.ButtonMask & Held(drag.Button)) == 0) { _drag = null; return; } // the release was lost, to a focus change say Apply(drag, motion.Relative); Handle(); break; } } + private static MouseButtonMask Held(MouseButton button) => button == MouseButton.Left ? MouseButtonMask.Left : MouseButtonMask.Middle; + + /// A drag is under way, so a second press is ignored as Blender's modal operator ignores it, unless the drag's own button is no longer held (its release was lost): then the drag ends and the press is new. + private bool StaleDrag(MouseButtonMask held) + { + if (_drag is { } drag && (held & Held(drag.Button)) == 0) _drag = null; + return _drag is null; + } + private void Handle() => GetViewport().SetInputAsHandled(); private void Apply(Drag drag, Vector2 move)