Add scroll to selected asset/content item on asset picker select menu open.
This commit is contained in:
@@ -475,22 +475,54 @@ namespace FlaxEditor.GUI
|
|||||||
if (_type != ScriptType.Null)
|
if (_type != ScriptType.Null)
|
||||||
{
|
{
|
||||||
// Show asset picker popup
|
// Show asset picker popup
|
||||||
AssetSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
|
var popup = AssetSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
|
||||||
{
|
{
|
||||||
SelectedItem = item;
|
SelectedItem = item;
|
||||||
RootWindow.Focus();
|
RootWindow.Focus();
|
||||||
Focus();
|
Focus();
|
||||||
});
|
});
|
||||||
|
if (_selected != null)
|
||||||
|
{
|
||||||
|
var selectedAssetName = Path.GetFileNameWithoutExtension(_selected.Path);
|
||||||
|
foreach (var child in popup.ItemsPanel.Children)
|
||||||
|
{
|
||||||
|
if (child is not ItemsListContextMenu.Item item)
|
||||||
|
continue;
|
||||||
|
if (string.Equals(item.Name, selectedAssetName, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
// Highlight and scroll to item
|
||||||
|
item.Focus();
|
||||||
|
popup.ScrollViewTo(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Show content item picker popup
|
// Show content item picker popup
|
||||||
ContentSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
|
var popup = ContentSearchPopup.Show(this, Button1Rect.BottomLeft, IsValid, item =>
|
||||||
{
|
{
|
||||||
SelectedItem = item;
|
SelectedItem = item;
|
||||||
RootWindow.Focus();
|
RootWindow.Focus();
|
||||||
Focus();
|
Focus();
|
||||||
});
|
});
|
||||||
|
if (_selectedItem != null)
|
||||||
|
{
|
||||||
|
var selectedItemName = _selectedItem.ShortName;
|
||||||
|
foreach (var child in popup.ItemsPanel.Children)
|
||||||
|
{
|
||||||
|
if (child is not ItemsListContextMenu.Item item)
|
||||||
|
continue;
|
||||||
|
if (string.Equals(item.Name, selectedItemName, StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
// Highlight and scroll to item
|
||||||
|
item.Focus();
|
||||||
|
popup.ScrollViewTo(item);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_selected != null || _selectedItem != null)
|
else if (_selected != null || _selectedItem != null)
|
||||||
|
|||||||
@@ -265,6 +265,15 @@ namespace FlaxEditor.GUI
|
|||||||
_searchBox.Focus();
|
_searchBox.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scrolls the scroll panel to a specific Item
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">The item to scroll to.</param>
|
||||||
|
public void ScrollViewTo(Item item)
|
||||||
|
{
|
||||||
|
_scrollPanel.ScrollViewTo(item, true);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sorts the items list (by item name by default).
|
/// Sorts the items list (by item name by default).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user