From 923fc58cd15237fde42f3572376dca98a23e57e9 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Tue, 18 Aug 2026 00:10:42 +0300 Subject: [PATCH] Trigger UI double-click actions with left mouse button only --- .../Content/Import/ImportFilesDialog.cs | 9 ++++++-- Source/Editor/Content/Items/ContentItem.cs | 10 +++++--- .../Dedicated/MeshReferenceEditor.cs | 17 ++++++++++---- .../Editors/FlaxObjectRefEditor.cs | 4 +++- .../CustomEditors/Editors/TypeEditor.cs | 1 + Source/Editor/GUI/AssetPicker.cs | 2 +- Source/Editor/GUI/ClickableLabel.cs | 3 ++- Source/Editor/GUI/CurveEditor.Contents.cs | 21 +++++++++-------- Source/Editor/GUI/Row.cs | 7 ++++-- Source/Editor/GUI/Timeline/Media.cs | 2 +- Source/Editor/GUI/Timeline/Track.cs | 2 +- Source/Editor/GUI/Tree/TreeNode.cs | 7 +++--- .../Archetypes/Animation.StateMachine.cs | 13 +++++++---- Source/Editor/Surface/SurfaceComment.cs | 2 +- Source/Editor/Surface/VisjectSurface.Input.cs | 2 +- Source/Editor/Windows/DebugLogWindow.cs | 9 ++++++-- Source/Editor/Windows/OutputLogWindow.cs | 21 +++++++++-------- .../Windows/Search/ContentSearchWindow.cs | 2 +- .../Windows/VisualScriptDebuggerWindow.cs | 11 ++++++--- Source/Engine/UI/GUI/CanvasContainer.cs | 5 +--- .../Engine/UI/GUI/Common/RichTextBoxBase.cs | 23 +++++++++++-------- Source/Engine/UI/GUI/Common/TextBox.cs | 2 +- 22 files changed, 110 insertions(+), 65 deletions(-) diff --git a/Source/Editor/Content/Import/ImportFilesDialog.cs b/Source/Editor/Content/Import/ImportFilesDialog.cs index f245f49ee..1f92834e4 100644 --- a/Source/Editor/Content/Import/ImportFilesDialog.cs +++ b/Source/Editor/Content/Import/ImportFilesDialog.cs @@ -186,8 +186,13 @@ namespace FlaxEditor.Content.Import /// protected override bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button) { - StartRenaming(); - return true; + if (button == MouseButton.Left) + { + StartRenaming(); + return true; + } + + return false; } public override bool OnKeyDown(KeyboardKeys key) diff --git a/Source/Editor/Content/Items/ContentItem.cs b/Source/Editor/Content/Items/ContentItem.cs index 6c4bd9ca6..939a644e2 100644 --- a/Source/Editor/Content/Items/ContentItem.cs +++ b/Source/Editor/Content/Items/ContentItem.cs @@ -796,10 +796,14 @@ namespace FlaxEditor.Content { Focus(); - // Open - (Parent as ContentView).OnItemDoubleClick(this); + if (button == MouseButton.Left) + { + // Open + (Parent as ContentView).OnItemDoubleClick(this); + return true; + } - return true; + return false; } /// diff --git a/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs b/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs index 9cb8ab57c..a4aa370c9 100644 --- a/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs +++ b/Source/Editor/CustomEditors/Dedicated/MeshReferenceEditor.cs @@ -179,11 +179,18 @@ namespace FlaxEditor.CustomEditors.Dedicated { Focus(); - // Open model editor window - if (_value.Actor is StaticModel staticModel) - Editor.Instance.ContentEditing.Open(staticModel.Model); - else if (_value.Actor is AnimatedModel animatedModel) - Editor.Instance.ContentEditing.Open(animatedModel.SkinnedModel); + if (button == MouseButton.Left) + { + // Open model editor window + if (_value.Actor is StaticModel staticModel) + Editor.Instance.ContentEditing.Open(staticModel.Model); + else if (_value.Actor is AnimatedModel animatedModel) + Editor.Instance.ContentEditing.Open(animatedModel.SkinnedModel); + else + return base.OnMouseDoubleClick(location, button); + + return true; + } return base.OnMouseDoubleClick(location, button); } diff --git a/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs b/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs index d7ab6d12b..b63866c9c 100644 --- a/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs +++ b/Source/Editor/CustomEditors/Editors/FlaxObjectRefEditor.cs @@ -395,7 +395,7 @@ namespace FlaxEditor.CustomEditors.Editors Focus(); // Check if has object selected - if (_value != null) + if (button == MouseButton.Left && _value != null) { if (_linkedTreeNode != null) { @@ -410,6 +410,8 @@ namespace FlaxEditor.CustomEditors.Editors Select(script.Actor); else if (_value is Asset asset) Editor.Instance.Windows.ContentWin.Select(asset); + + return true; } return base.OnMouseDoubleClick(location, button); diff --git a/Source/Editor/CustomEditors/Editors/TypeEditor.cs b/Source/Editor/CustomEditors/Editors/TypeEditor.cs index 148d75169..9b0a0d3db 100644 --- a/Source/Editor/CustomEditors/Editors/TypeEditor.cs +++ b/Source/Editor/CustomEditors/Editors/TypeEditor.cs @@ -236,6 +236,7 @@ namespace FlaxEditor.CustomEditors.Editors if (button == MouseButton.Left && _value != ScriptType.Null) { Editor.Instance.ContentEditing.Open(_value.ContentItem); + return true; } return base.OnMouseDoubleClick(location, button); diff --git a/Source/Editor/GUI/AssetPicker.cs b/Source/Editor/GUI/AssetPicker.cs index 70fe2394c..f9c322c32 100644 --- a/Source/Editor/GUI/AssetPicker.cs +++ b/Source/Editor/GUI/AssetPicker.cs @@ -341,7 +341,7 @@ namespace FlaxEditor.GUI { Focus(); - if (Validator.SelectedItem != null && IconRect.Contains(location)) + if (button == MouseButton.Left && Validator.SelectedItem != null && IconRect.Contains(location)) { // Open it Editor.Instance.ContentEditing.Open(Validator.SelectedItem); diff --git a/Source/Editor/GUI/ClickableLabel.cs b/Source/Editor/GUI/ClickableLabel.cs index 302cb381d..5e6348aa6 100644 --- a/Source/Editor/GUI/ClickableLabel.cs +++ b/Source/Editor/GUI/ClickableLabel.cs @@ -34,7 +34,8 @@ namespace FlaxEditor.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - DoubleClick?.Invoke(); + if (button == MouseButton.Left) + DoubleClick?.Invoke(); return base.OnMouseDoubleClick(location, button); } diff --git a/Source/Editor/GUI/CurveEditor.Contents.cs b/Source/Editor/GUI/CurveEditor.Contents.cs index 75f37d457..8cc2e24d8 100644 --- a/Source/Editor/GUI/CurveEditor.Contents.cs +++ b/Source/Editor/GUI/CurveEditor.Contents.cs @@ -554,16 +554,19 @@ namespace FlaxEditor.GUI if (base.OnMouseDoubleClick(location, button)) return true; - // Add keyframe on double click - var child = GetChildAt(location); - if (child is not KeyframePoint && - child is not TangentPoint && - _editor.KeyframesCount < _editor.MaxKeyframes) + if (button == MouseButton.Left) { - var viewRect = _editor._mainPanel.GetClientArea(); - var pos = PointToKeyframes(location, ref viewRect); - _editor.AddKeyframe(pos); - return true; + // Add keyframe on double click + var child = GetChildAt(location); + if (child is not KeyframePoint && + child is not TangentPoint && + _editor.KeyframesCount < _editor.MaxKeyframes) + { + var viewRect = _editor._mainPanel.GetClientArea(); + var pos = PointToKeyframes(location, ref viewRect); + _editor.AddKeyframe(pos); + return true; + } } return false; diff --git a/Source/Editor/GUI/Row.cs b/Source/Editor/GUI/Row.cs index f256e0263..d0461abfa 100644 --- a/Source/Editor/GUI/Row.cs +++ b/Source/Editor/GUI/Row.cs @@ -257,8 +257,11 @@ namespace FlaxEditor.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - DoubleClick?.Invoke(); - RowDoubleClick?.Invoke(this); + if (button == MouseButton.Left) + { + DoubleClick?.Invoke(); + RowDoubleClick?.Invoke(this); + } return base.OnMouseDoubleClick(location, button); } diff --git a/Source/Editor/GUI/Timeline/Media.cs b/Source/Editor/GUI/Timeline/Media.cs index 1dc5e8b7d..4663c5cfa 100644 --- a/Source/Editor/GUI/Timeline/Media.cs +++ b/Source/Editor/GUI/Timeline/Media.cs @@ -478,7 +478,7 @@ namespace FlaxEditor.GUI.Timeline if (base.OnMouseDoubleClick(location, button)) return true; - if (PropertiesEditObject != null) + if (button == MouseButton.Left && PropertiesEditObject != null) { Timeline.ShowEditPopup(PropertiesEditObject, PointToParent(Timeline, location), Track); return true; diff --git a/Source/Editor/GUI/Timeline/Track.cs b/Source/Editor/GUI/Timeline/Track.cs index a102e6dda..99910d1fc 100644 --- a/Source/Editor/GUI/Timeline/Track.cs +++ b/Source/Editor/GUI/Timeline/Track.cs @@ -1286,7 +1286,7 @@ namespace FlaxEditor.GUI.Timeline if (base.OnMouseDoubleClick(location, button)) return true; - if (CanRename && TestHeaderHit(ref location)) + if (button == MouseButton.Left && CanRename && TestHeaderHit(ref location)) { StartRenaming(); return true; diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs index 4f00acd1a..8b908fef4 100644 --- a/Source/Editor/GUI/Tree/TreeNode.cs +++ b/Source/Editor/GUI/Tree/TreeNode.cs @@ -508,17 +508,18 @@ namespace FlaxEditor.GUI.Tree /// True if event has been handled. protected virtual bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button) { - if (HasAnyVisibleChild && _animationProgress >= 1.0f) + if (button == MouseButton.Left && HasAnyVisibleChild && _animationProgress >= 1.0f) { // Toggle open state (ignored while an expand/collapse animation is running) if (_opened) Collapse(); else Expand(); + + return true; } - // Handled - return true; + return false; } /// diff --git a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs index 772d7af0e..aeca78554 100644 --- a/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs +++ b/Source/Editor/Surface/Archetypes/Animation.StateMachine.cs @@ -213,7 +213,7 @@ namespace FlaxEditor.Surface.Archetypes if (base.OnMouseDoubleClick(location, button)) return true; - if (_headerRect.Contains(ref location)) + if (button == MouseButton.Left && _headerRect.Contains(ref location)) { StartRenaming(); return true; @@ -1129,7 +1129,7 @@ namespace FlaxEditor.Surface.Archetypes if (base.OnMouseDoubleClick(location, button)) return true; - if (_renameButtonRect.Contains(ref location) || _closeButtonRect.Contains(ref location)) + if (button == MouseButton.Left && _renameButtonRect.Contains(ref location) || _closeButtonRect.Contains(ref location)) return true; return false; @@ -1489,8 +1489,13 @@ namespace FlaxEditor.Surface.Archetypes if (base.OnMouseDoubleClick(location, button)) return true; - Edit(); - return true; + if (button == MouseButton.Left) + { + Edit(); + return true; + } + + return false; } /// diff --git a/Source/Editor/Surface/SurfaceComment.cs b/Source/Editor/Surface/SurfaceComment.cs index 60fd3e272..53a25069e 100644 --- a/Source/Editor/Surface/SurfaceComment.cs +++ b/Source/Editor/Surface/SurfaceComment.cs @@ -236,7 +236,7 @@ namespace FlaxEditor.Surface return true; // Rename - if (_headerRect.Contains(ref location) && Surface.CanEdit) + if (button == MouseButton.Left && _headerRect.Contains(ref location) && Surface.CanEdit) { StartRenaming(); return true; diff --git a/Source/Editor/Surface/VisjectSurface.Input.cs b/Source/Editor/Surface/VisjectSurface.Input.cs index 249cec0df..ca15079c0 100644 --- a/Source/Editor/Surface/VisjectSurface.Input.cs +++ b/Source/Editor/Surface/VisjectSurface.Input.cs @@ -464,7 +464,7 @@ namespace FlaxEditor.Surface CustomMouseDoubleClick?.Invoke(ref location, button, ref handled); // Insert reroute node - if (!handled && CanEdit && CanUseNodeType(7, 29)) + if (button == MouseButton.Left && !handled && CanEdit && CanUseNodeType(7, 29)) { var mousePos = _rootControl.PointFromParent(ref _mousePos); if (IntersectsConnection(mousePos, out InputBox inputBox, out OutputBox outputBox, MouseOverConnectionDistance) && GetControlUnderMouse() == null) diff --git a/Source/Editor/Windows/DebugLogWindow.cs b/Source/Editor/Windows/DebugLogWindow.cs index 5b5abf1e2..9ae4fad81 100644 --- a/Source/Editor/Windows/DebugLogWindow.cs +++ b/Source/Editor/Windows/DebugLogWindow.cs @@ -239,8 +239,13 @@ namespace FlaxEditor.Windows public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - Open(); - return true; + if (button == MouseButton.Left) + { + Open(); + return true; + } + + return false; } /// diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index 77c393bde..b28fb2e61 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -104,18 +104,21 @@ namespace FlaxEditor.Windows /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - // Click on text block - int textLength = TextLength; - if (textLength != 0) + if (button == MouseButton.Left) { - var hitPos = CharIndexAtPoint(ref location); - if (hitPos != -1 && GetTextBlock(hitPos, out var textBlock) && textBlock.Tag is TextBlockTag tag) + // Click on text block + int textLength = TextLength; + if (textLength != 0) { - switch (tag.Type) + var hitPos = CharIndexAtPoint(ref location); + if (hitPos != -1 && GetTextBlock(hitPos, out var textBlock) && textBlock.Tag is TextBlockTag tag) { - case TextBlockTag.Types.CodeLocation: - Window.Editor.CodeEditing.OpenFile(tag.Url, tag.Line); - return true; + switch (tag.Type) + { + case TextBlockTag.Types.CodeLocation: + Window.Editor.CodeEditing.OpenFile(tag.Url, tag.Line); + return true; + } } } } diff --git a/Source/Editor/Windows/Search/ContentSearchWindow.cs b/Source/Editor/Windows/Search/ContentSearchWindow.cs index 849ed9826..4c9c2bfee 100644 --- a/Source/Editor/Windows/Search/ContentSearchWindow.cs +++ b/Source/Editor/Windows/Search/ContentSearchWindow.cs @@ -162,7 +162,7 @@ namespace FlaxEngine.Windows.Search /// protected override bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button) { - if (Navigate != null) + if (button == MouseButton.Left && Navigate != null) { Navigate.Invoke(this); return true; diff --git a/Source/Editor/Windows/VisualScriptDebuggerWindow.cs b/Source/Editor/Windows/VisualScriptDebuggerWindow.cs index 93fe4d8ca..96a697746 100644 --- a/Source/Editor/Windows/VisualScriptDebuggerWindow.cs +++ b/Source/Editor/Windows/VisualScriptDebuggerWindow.cs @@ -71,9 +71,14 @@ namespace FlaxEditor.Windows /// protected override bool OnMouseDoubleClickHeader(ref Float2 location, MouseButton button) { - var node = GetNode(Tag); - ((VisualScriptWindow)node?.Surface.Owner)?.ShowNode(node); - return true; + if (button == MouseButton.Left) + { + var node = GetNode(Tag); + ((VisualScriptWindow)node?.Surface.Owner)?.ShowNode(node); + return true; + } + + return false; } } diff --git a/Source/Engine/UI/GUI/CanvasContainer.cs b/Source/Engine/UI/GUI/CanvasContainer.cs index 378a86244..3c192d4d2 100644 --- a/Source/Engine/UI/GUI/CanvasContainer.cs +++ b/Source/Engine/UI/GUI/CanvasContainer.cs @@ -250,10 +250,7 @@ namespace FlaxEngine.GUI // Test 3D if (RayCast3D(ref location, out var hit, out var hitLocation)) - { - hit.OnMouseDoubleClick(hitLocation, button); - return true; - } + return hit.OnMouseDoubleClick(hitLocation, button); return false; } diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index 97e1d88a5..a08c2f31d 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -257,17 +257,20 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - // Select the word under the mouse - int textLength = TextLength; - if (textLength != 0 && IsSelectable) + if (button == MouseButton.Left) { - var hitPos = CharIndexAtPoint(ref location); - int spaceLoc = _text.LastIndexOfAny(Separators, hitPos - 2); - var left = spaceLoc == -1 ? 0 : spaceLoc + 1; - spaceLoc = _text.IndexOfAny(Separators, Math.Min(hitPos + 1, _text.Length)); - var right = spaceLoc == -1 ? textLength : spaceLoc; - Deselect(); - SetSelection(left, right); + // Select the word under the mouse + int textLength = TextLength; + if (textLength != 0 && IsSelectable) + { + var hitPos = CharIndexAtPoint(ref location); + int spaceLoc = _text.LastIndexOfAny(Separators, hitPos - 2); + var left = spaceLoc == -1 ? 0 : spaceLoc + 1; + spaceLoc = _text.IndexOfAny(Separators, Math.Min(hitPos + 1, _text.Length)); + var right = spaceLoc == -1 ? textLength : spaceLoc; + Deselect(); + SetSelection(left, right); + } } return base.OnMouseDoubleClick(location, button); diff --git a/Source/Engine/UI/GUI/Common/TextBox.cs b/Source/Engine/UI/GUI/Common/TextBox.cs index c077597aa..c3d12a03d 100644 --- a/Source/Engine/UI/GUI/Common/TextBox.cs +++ b/Source/Engine/UI/GUI/Common/TextBox.cs @@ -328,7 +328,7 @@ namespace FlaxEngine.GUI /// public override bool OnMouseDoubleClick(Float2 location, MouseButton button) { - if (IsSelectable) + if (button == MouseButton.Left && IsSelectable) { SelectAll(); }