Fix sorting items in various contextual list popups in Editor

This commit is contained in:
Wojciech Figat
2022-03-25 15:36:30 +01:00
parent a917397090
commit 3e9b6caa1c
11 changed files with 23 additions and 10 deletions

View File

@@ -273,7 +273,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
cm.AddItem(item);
}
cm.ItemClicked += item => action((string)item.Tag);
cm.SortChildren();
cm.SortItems();
cm.Show(button.Parent, button.BottomLeft);
}

View File

@@ -71,7 +71,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
cm.AddItem(new TypeSearchPopup.TypeItemView(scripts[i]));
}
cm.ItemClicked += item => AddScript((ScriptType)item.Tag);
cm.SortChildren();
cm.SortItems();
cm.Show(this, button.BottomLeft);
}

View File

@@ -642,7 +642,7 @@ namespace FlaxEditor.CustomEditors.Dedicated
cm.AddItem(new TypeSearchPopup.TypeItemView(controlTypes[i]));
}
cm.ItemClicked += controlType => SetType((ScriptType)controlType.Tag);
cm.SortChildren();
cm.SortItems();
cm.Show(button.Parent, button.BottomLeft);
}

View File

@@ -263,6 +263,19 @@ namespace FlaxEditor.GUI
PerformLayout(true);
_searchBox.Focus();
}
/// <summary>
/// Sorts the items list (by item name by default).
/// </summary>
public void SortItems()
{
ItemsPanel.SortChildren();
if (_categoryPanels != null)
{
for (int i = 0; i < _categoryPanels.Count; i++)
_categoryPanels[i].SortChildren();
}
}
/// <summary>
/// Adds the item to the view and registers for the click event.

View File

@@ -67,7 +67,7 @@ namespace FlaxEditor.GUI
{
Find(Level.GetScene(i));
}
SortChildren();
SortItems();
}
private void OnItemClicked(Item item)

View File

@@ -122,7 +122,7 @@ namespace FlaxEditor.GUI
if (project.Content != null)
FindAssets(project.Content.Folder);
}
SortChildren();
SortItems();
}
private void OnItemClicked(Item item)

View File

@@ -78,7 +78,7 @@ namespace FlaxEditor.GUI
{
Find(Level.GetScene(i));
}
SortChildren();
SortItems();
}
private void OnItemClicked(Item item)

View File

@@ -95,7 +95,7 @@ namespace FlaxEditor.GUI
}
}
}
SortChildren();
SortItems();
}
private void OnItemClicked(Item item)

View File

@@ -126,7 +126,7 @@ namespace FlaxEditor.Surface.Archetypes
});
}
cm.ItemClicked += item => AddModule((ushort)item.Tag);
cm.SortChildren();
cm.SortItems();
cm.Show(this, button.BottomLeft);
}

View File

@@ -461,7 +461,7 @@ namespace FlaxEditor.Surface
cm.AddItem(item);
}
cm.ItemClicked += OnAddParameterItemClicked;
cm.SortChildren();
cm.SortItems();
cm.Show(button.Parent, button.BottomLeft);
}

View File

@@ -188,7 +188,7 @@ namespace FlaxEditor.Windows.Assets
cm.AddItem(item);
}
cm.ItemClicked += (ItemsListContextMenu.Item item) => window.SetParamType(index, (ScriptType)item.Tag);
cm.SortChildren();
cm.SortItems();
cm.Show(window, window.PointFromScreen(Input.MouseScreenPosition));
});
b.Enabled = window._canEdit;