From cd7233d559dded4da4ec88e5d6f498e18de22ff8 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 16 Jun 2025 14:10:44 +0200 Subject: [PATCH 1/3] allow the user to unfold folded categories when scrolling with keyboard --- Source/Editor/GUI/ItemsListContextMenu.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index 58f8c2eb4..0f138fb80 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -227,9 +227,8 @@ namespace FlaxEditor.GUI { int order = -1 * SortScore.CompareTo(otherItem.SortScore); if (order == 0) - { order = string.Compare(Name, otherItem.Name, StringComparison.Ordinal); - } + return order; } return base.Compare(other); @@ -535,6 +534,12 @@ namespace FlaxEditor.GUI return result; } + private void ExpandToItem(Item item) + { + if (item.Parent is DropPanel dropPanel) + dropPanel.Open(false); + } + /// protected override void OnShow() { @@ -564,7 +569,7 @@ namespace FlaxEditor.GUI Hide(); return true; case KeyboardKeys.Backspace: - // Alow the user to quickly focus the searchbar + // Allow the user to quickly focus the searchbar if (_searchBox != null && !_searchBox.IsFocused) { _searchBox.Focus(); @@ -590,6 +595,11 @@ namespace FlaxEditor.GUI // Focus the next item nextItem.Focus(); + + // Allow the user to expand groups while scrolling + if (Root.GetKey(KeyboardKeys.Control)) + ExpandToItem(nextItem); + _scrollPanel.ScrollViewTo(nextItem); return true; case KeyboardKeys.Return: From d110237423949a04cb8da04de342c9dac16873f9 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 16 Jun 2025 14:51:29 +0200 Subject: [PATCH 2/3] fix GetVisibleItems() to only get visible items --- Source/Editor/GUI/ItemsListContextMenu.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index 0f138fb80..e2a06342d 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -522,7 +522,7 @@ namespace FlaxEditor.GUI for (int i = 0; i < _categoryPanels.Count; i++) { var category = _categoryPanels[i]; - if (!category.Visible) + if (!category.Visible || (category is DropPanel panel && panel.IsClosed)) continue; for (int j = 0; j < category.Children.Count; j++) { From 8164ce924fd5867e3f236736b0baff3f23dbf482 Mon Sep 17 00:00:00 2001 From: xxSeys1 Date: Mon, 16 Jun 2025 15:30:51 +0200 Subject: [PATCH 3/3] fix unfolding to actually work --- Source/Editor/GUI/ItemsListContextMenu.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index e2a06342d..6cb5a84fb 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -508,7 +508,7 @@ namespace FlaxEditor.GUI OnSearchFilterChanged(); } - private List GetVisibleItems() + private List GetVisibleItems(bool ignoreFoldedCategories) { var result = new List(); var items = ItemsPanel.Children; @@ -522,7 +522,7 @@ namespace FlaxEditor.GUI for (int i = 0; i < _categoryPanels.Count; i++) { var category = _categoryPanels[i]; - if (!category.Visible || (category is DropPanel panel && panel.IsClosed)) + if (!category.Visible || (ignoreFoldedCategories && category is DropPanel panel && panel.IsClosed)) continue; for (int j = 0; j < category.Children.Count; j++) { @@ -587,8 +587,14 @@ namespace FlaxEditor.GUI } // Get the next item - var items = GetVisibleItems(); + bool controlDown = Root.GetKey(KeyboardKeys.Control); + var items = GetVisibleItems(!controlDown); var focusedIndex = items.IndexOf(focusedItem); + + // If the user hasn't selected anything yet and is holding control, focus first folded item + if (focusedIndex == -1 && controlDown) + focusedIndex = GetVisibleItems(true).Count - 1; + int delta = key == KeyboardKeys.ArrowDown ? -1 : 1; int nextIndex = Mathf.Wrap(focusedIndex - delta, 0, items.Count - 1); var nextItem = items[nextIndex]; @@ -597,7 +603,7 @@ namespace FlaxEditor.GUI nextItem.Focus(); // Allow the user to expand groups while scrolling - if (Root.GetKey(KeyboardKeys.Control)) + if (controlDown) ExpandToItem(nextItem); _scrollPanel.ScrollViewTo(nextItem); @@ -611,7 +617,7 @@ namespace FlaxEditor.GUI else { // Select first item if no item is focused (most likely to be the best result), saves the user from pressing arrow down first - var visibleItems = GetVisibleItems(); + var visibleItems = GetVisibleItems(true); if (visibleItems.Count > 0) { OnClickItem(visibleItems[0]);