From c10cfc8e451d4d219c205459aa87036f22dae69b Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Wed, 13 May 2026 10:42:56 +0200 Subject: [PATCH] Fix output log history popup management to smoother usage --- .../Editor/GUI/ContextMenu/ContextMenuBase.cs | 2 +- Source/Editor/Windows/OutputLogWindow.cs | 35 +++++++++++++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs index d3af7b5cd..3eace0363 100644 --- a/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs +++ b/Source/Editor/GUI/ContextMenu/ContextMenuBase.cs @@ -355,7 +355,7 @@ namespace FlaxEditor.GUI.ContextMenu if (_previouslyFocused != null) { _previouslyFocused.RootWindow?.Focus(); - _previouslyFocused.Focus(); + _previouslyFocused?.Focus(); _previouslyFocused = null; } diff --git a/Source/Editor/Windows/OutputLogWindow.cs b/Source/Editor/Windows/OutputLogWindow.cs index b88c06b27..1478a9ac9 100644 --- a/Source/Editor/Windows/OutputLogWindow.cs +++ b/Source/Editor/Windows/OutputLogWindow.cs @@ -176,7 +176,8 @@ namespace FlaxEditor.Windows if (Owner != null && (!Owner._searchPopup?.Visible ?? true)) { // Focus back the input field as user want to modify command from history - Owner._searchPopup?.Hide(); + Owner.HideHistory(); + Owner.HideSearch(); Owner.RootWindow.Focus(); Owner.Focus(); Owner.OnKeyDown(key); @@ -209,6 +210,7 @@ namespace FlaxEditor.Windows private OutputLogWindow _window; private ItemsListContextMenu _searchPopup; + private ItemsListContextMenu _historyPopup; private bool _isSettingText; public CommandLineBox(float x, float y, float width, OutputLogWindow window) @@ -226,6 +228,24 @@ namespace FlaxEditor.Windows _isSettingText = false; } + private void HideSearch() + { + if (_searchPopup != null) + { + _searchPopup.Hide(); + _searchPopup = null; + } + } + + private void HideHistory() + { + if (_historyPopup != null) + { + _historyPopup.Dispose(); + _historyPopup = null; + } + } + private void ShowPopup(ref ItemsListContextMenu cm, IEnumerable commands, string searchText = null) { if (cm == null) @@ -295,7 +315,7 @@ namespace FlaxEditor.Windows private void OnRootWindowLostFocus() { // Prevent popup from staying active when editor window looses focus - _searchPopup?.Hide(); + HideSearch(); if (RootWindow?.Window != null) RootWindow.Window.LostFocus -= OnRootWindowLostFocus; } @@ -330,6 +350,7 @@ namespace FlaxEditor.Windows if (isWhitespaceOnly) DebugCommands.GetAllCommands(out commands); + HideHistory(); ShowPopup(ref _searchPopup, isWhitespaceOnly ? commands : matches, text); if (isWhitespaceOnly) @@ -342,7 +363,7 @@ namespace FlaxEditor.Windows return; } } - _searchPopup?.Hide(); + HideSearch(); } /// @@ -353,7 +374,8 @@ namespace FlaxEditor.Windows case KeyboardKeys.Return: { // Run command - _searchPopup?.Hide(); + HideSearch(); + HideHistory(); var command = Text.Trim(); if (command.Length == 0) return true; @@ -430,9 +452,8 @@ namespace FlaxEditor.Windows if (_window._commandHistory != null && _window._commandHistory.Count != 0) { // Show command history popup - _searchPopup?.Hide(); - ItemsListContextMenu cm = null; - ShowPopup(ref cm, _window._commandHistory); + HideSearch(); + ShowPopup(ref _historyPopup, _window._commandHistory); } } return true;