From 50871d8885084e08f1886849a85a1308ecc0803a Mon Sep 17 00:00:00 2001 From: Saas Date: Wed, 9 Jul 2025 18:41:41 +0200 Subject: [PATCH] simplify and fix edge case in item list scrolling while holding control --- Source/Editor/GUI/ItemsListContextMenu.cs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/Source/Editor/GUI/ItemsListContextMenu.cs b/Source/Editor/GUI/ItemsListContextMenu.cs index 6cb5a84fb..9049eb9b4 100644 --- a/Source/Editor/GUI/ItemsListContextMenu.cs +++ b/Source/Editor/GUI/ItemsListContextMenu.cs @@ -514,19 +514,14 @@ namespace FlaxEditor.GUI var items = ItemsPanel.Children; for (int i = 0; i < items.Count; i++) { - if (items[i] is Item item && item.Visible) - result.Add(item); - } - if (_categoryPanels != null) - { - for (int i = 0; i < _categoryPanels.Count; i++) + var item = items[i]; + if (item is Item item1 && item1.Visible) + result.Add(item1); + else if (!ignoreFoldedCategories && item is DropPanel panel && item.Visible) { - var category = _categoryPanels[i]; - if (!category.Visible || (ignoreFoldedCategories && category is DropPanel panel && panel.IsClosed)) - continue; - for (int j = 0; j < category.Children.Count; j++) + for (int j = 0; j < panel.Children.Count; j++) { - if (category.Children[j] is Item item2 && item2.Visible) + if (panel.Children[j] is Item item2 && item2.Visible) result.Add(item2); } } @@ -591,10 +586,6 @@ namespace FlaxEditor.GUI 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];