From b63753b4d5b332698ae893f5c82cd80fd74f00f2 Mon Sep 17 00:00:00 2001 From: stefnotch Date: Sat, 2 Jan 2021 13:30:12 +0100 Subject: [PATCH] Return focus to the previous control when closing a context menu Fixes the fancy Visject input stuff --- Source/Editor/GUI/ContextMenu/ContextMenuBase.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index 2c3846f82..86bcd914e 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -45,6 +45,7 @@ namespace FlaxEditor.GUI.ContextMenu private bool _isSubMenu; private ContextMenuBase _childCM; private Window _window; + private Control _previouslyFocused; /// /// Returns true if context menu is opened @@ -185,6 +186,7 @@ namespace FlaxEditor.GUI.ContextMenu return; _window.Show(); PerformLayout(); + _previouslyFocused = parentWin.FocusedControl; Focus(); OnShow(); } @@ -221,6 +223,10 @@ namespace FlaxEditor.GUI.ContextMenu _parentCM = null; } + // Return focus + _previouslyFocused?.RootWindow?.Focus(); + _previouslyFocused?.Focus(); + // Hide Visible = false; OnHide();