From 3ddaa6da1a8bfebc71105141a0c3ed65b236bd49 Mon Sep 17 00:00:00 2001 From: Chandler Cox Date: Sat, 18 Feb 2023 07:47:49 -0600 Subject: [PATCH] fix issue of child context menu hiding when de-hovered then re-hovered. Fixed issue of clicking on child cm hiding child. --- .../GUI/ContextMenu/ContextMenuChildMenu.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs index 0256d2bee..7af36fae0 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuChildMenu.cs @@ -55,8 +55,6 @@ namespace FlaxEditor.GUI.ContextMenu /// public override void OnMouseEnter(Float2 location) { - base.OnMouseEnter(location); - // Skip if has no children if (ContextMenu.HasChildren == false) return; @@ -66,8 +64,28 @@ namespace FlaxEditor.GUI.ContextMenu if (parentContextMenu == ContextMenu) return; + if (ContextMenu.IsOpened) + return; + + base.OnMouseEnter(location); + // Hide parent CM popups and set itself as child parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Float2(Width, 0))); } + + /// + public override bool OnMouseUp(Float2 location, MouseButton button) + { + // Skip if already shown + var parentContextMenu = ParentContextMenu; + if (parentContextMenu == ContextMenu) + return true; + if (ContextMenu.IsOpened) + return true; + + // Hide parent CM popups and set itself as child + parentContextMenu.ShowChild(ContextMenu, PointToParent(ParentContextMenu, new Float2(Width, 0))); + return base.OnMouseUp(location, button); + } } }