From 6b634322ff871ee99624153718c7422fd4c87483 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 12 Feb 2023 14:10:11 +0200 Subject: [PATCH] Fix active tooltip preventing TreeNode selection --- Source/Editor/GUI/Tree/TreeNode.cs | 39 ++++++++++++++++++------------ 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/Source/Editor/GUI/Tree/TreeNode.cs b/Source/Editor/GUI/Tree/TreeNode.cs index 54aeedb9a..f2c8e2d6a 100644 --- a/Source/Editor/GUI/Tree/TreeNode.cs +++ b/Source/Editor/GUI/Tree/TreeNode.cs @@ -700,6 +700,8 @@ namespace FlaxEditor.GUI.Tree /// public override bool OnMouseDown(Float2 location, MouseButton button) { + UpdateMouseOverFlags(location); + // Check if mouse hits bar and node isn't a root if (_mouseOverHeader) { @@ -728,6 +730,8 @@ namespace FlaxEditor.GUI.Tree /// public override bool OnMouseUp(Float2 location, MouseButton button) { + UpdateMouseOverFlags(location); + // Clear flag for left button if (button == MouseButton.Left) { @@ -815,21 +819,7 @@ namespace FlaxEditor.GUI.Tree /// public override void OnMouseMove(Float2 location) { - // Cache flags - _mouseOverArrow = HasAnyVisibleChild && ArrowRect.Contains(location); - _mouseOverHeader = new Rectangle(0, 0, Width, _headerHeight - 1).Contains(location); - if (_mouseOverHeader) - { - // Allow non-scrollable controls to stay on top of the header and override the mouse behaviour - for (int i = 0; i < Children.Count; i++) - { - if (!Children[i].IsScrollable && IntersectsChildContent(Children[i], location, out _)) - { - _mouseOverHeader = false; - break; - } - } - } + UpdateMouseOverFlags(location); // Check if start drag and drop if (_isMouseDown && Float2.Distance(_mouseDownPos, location) > 10.0f) @@ -852,6 +842,25 @@ namespace FlaxEditor.GUI.Tree } } + private void UpdateMouseOverFlags(Vector2 location) + { + // Cache flags + _mouseOverArrow = HasAnyVisibleChild && ArrowRect.Contains(location); + _mouseOverHeader = new Rectangle(0, 0, Width, _headerHeight - 1).Contains(location); + if (_mouseOverHeader) + { + // Allow non-scrollable controls to stay on top of the header and override the mouse behaviour + for (int i = 0; i < Children.Count; i++) + { + if (!Children[i].IsScrollable && IntersectsChildContent(Children[i], location, out _)) + { + _mouseOverHeader = false; + break; + } + } + } + } + /// public override void OnMouseLeave() {