From 6f5308126b49f6c9dde3a6f347b5f92f927db891 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 3 Jun 2025 14:52:45 +0200 Subject: [PATCH] Fix focus issue after closing context menu --- Source/Editor/GUI/ContextMenu/ContextMenuBase.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index d1cffa75d..d7534b15b 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -285,6 +285,17 @@ namespace FlaxEditor.GUI.ContextMenu } } + private static void ForceDefocus(ContainerControl c) + { + foreach (var cc in c.Children) + { + if (cc.ContainsFocus) + cc.Defocus(); + if (cc is ContainerControl ccc) + ForceDefocus(ccc); + } + } + /// /// Hide popup menu and all child menus. /// @@ -299,6 +310,9 @@ namespace FlaxEditor.GUI.ContextMenu // Close child HideChild(); + // Force defocus + ForceDefocus(this); + // Unlink from window Parent = null;