From bc7bf7266091695f2007bf2880f1eecf930db402 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 1 Jan 2023 21:42:35 +0100 Subject: [PATCH] Fix case when child context menu is already hidden and changed to other from code --- Source/Editor/GUI/ContextMenu/ContextMenuBase.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index 0bd87082d..4df17364a 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -356,10 +356,15 @@ namespace FlaxEditor.GUI.ContextMenu private void OnWindowGotFocus() { - if (_childCM != null && _window && _window.IsForegroundWindow) + var child = _childCM; + if (child != null && _window && _window.IsForegroundWindow) { // Hide child if user clicked over parent (do it next frame to process other events before - eg. child windows focus loss) - FlaxEngine.Scripting.InvokeOnUpdate(HideChild); + FlaxEngine.Scripting.InvokeOnUpdate(() => + { + if (child == _childCM) + HideChild(); + }); } }