Merge branch 'xxSeys1-ContentFinderImprovements'
This commit is contained in:
@@ -42,6 +42,7 @@ namespace FlaxEditor.Windows.Search
|
||||
if (value == _selectedItem || (value != null && !_matchedItems.Contains(value)))
|
||||
return;
|
||||
|
||||
// Restore the previous selected item to the non-selected color
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
_selectedItem.BackgroundColor = Color.Transparent;
|
||||
@@ -54,6 +55,7 @@ namespace FlaxEditor.Windows.Search
|
||||
_selectedItem.BackgroundColor = Style.Current.BackgroundSelected;
|
||||
if (_matchedItems.Count > VisibleItemCount)
|
||||
{
|
||||
_selectedItem.Focus();
|
||||
_resultPanel.ScrollViewTo(_selectedItem, true);
|
||||
}
|
||||
}
|
||||
@@ -180,39 +182,17 @@ namespace FlaxEditor.Windows.Search
|
||||
switch (key)
|
||||
{
|
||||
case KeyboardKeys.ArrowDown:
|
||||
{
|
||||
if (_matchedItems.Count == 0)
|
||||
return true;
|
||||
int currentPos;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
currentPos = _matchedItems.IndexOf(_selectedItem) + 1;
|
||||
if (currentPos >= _matchedItems.Count)
|
||||
currentPos--;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPos = 0;
|
||||
}
|
||||
SelectedItem = _matchedItems[currentPos];
|
||||
return true;
|
||||
}
|
||||
case KeyboardKeys.ArrowUp:
|
||||
{
|
||||
if (_matchedItems.Count == 0)
|
||||
return true;
|
||||
int currentPos;
|
||||
if (_selectedItem != null)
|
||||
{
|
||||
currentPos = _matchedItems.IndexOf(_selectedItem) - 1;
|
||||
if (currentPos < 0)
|
||||
currentPos = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentPos = 0;
|
||||
}
|
||||
SelectedItem = _matchedItems[currentPos];
|
||||
|
||||
var focusedIndex = _matchedItems.IndexOf(_selectedItem);
|
||||
int delta = key == KeyboardKeys.ArrowDown ? -1 : 1;
|
||||
int nextIndex = Mathf.Wrap(focusedIndex - delta, 0, _matchedItems.Count - 1);
|
||||
var nextItem = _matchedItems[nextIndex];
|
||||
|
||||
SelectedItem = nextItem;
|
||||
return true;
|
||||
}
|
||||
case KeyboardKeys.Return:
|
||||
@@ -234,6 +214,17 @@ namespace FlaxEditor.Windows.Search
|
||||
Hide();
|
||||
return true;
|
||||
}
|
||||
case KeyboardKeys.Backspace:
|
||||
{
|
||||
// Alow the user to quickly focus the searchbar
|
||||
if (_searchBox != null && !_searchBox.IsFocused)
|
||||
{
|
||||
_searchBox.Focus();
|
||||
_searchBox.SelectAll();
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnKeyDown(key);
|
||||
|
||||
Reference in New Issue
Block a user