Return focus to the previous control when closing a context menu

Fixes the fancy Visject input stuff
This commit is contained in:
stefnotch
2021-01-02 13:30:12 +01:00
parent e5286510d1
commit b63753b4d5

View File

@@ -45,6 +45,7 @@ namespace FlaxEditor.GUI.ContextMenu
private bool _isSubMenu; private bool _isSubMenu;
private ContextMenuBase _childCM; private ContextMenuBase _childCM;
private Window _window; private Window _window;
private Control _previouslyFocused;
/// <summary> /// <summary>
/// Returns true if context menu is opened /// Returns true if context menu is opened
@@ -185,6 +186,7 @@ namespace FlaxEditor.GUI.ContextMenu
return; return;
_window.Show(); _window.Show();
PerformLayout(); PerformLayout();
_previouslyFocused = parentWin.FocusedControl;
Focus(); Focus();
OnShow(); OnShow();
} }
@@ -221,6 +223,10 @@ namespace FlaxEditor.GUI.ContextMenu
_parentCM = null; _parentCM = null;
} }
// Return focus
_previouslyFocused?.RootWindow?.Focus();
_previouslyFocused?.Focus();
// Hide // Hide
Visible = false; Visible = false;
OnHide(); OnHide();