enhance: allow to use arrow up/down to select workspace/tab after switcher popups (#1711)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-08-28 15:29:54 +08:00
parent 7c0f280ac2
commit 0c9e6283f1
2 changed files with 36 additions and 8 deletions

View File

@@ -32,14 +32,28 @@ namespace SourceGit.Views
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Down && PagesListBox.ItemCount > 0)
if (PagesListBox.ItemCount == 0)
return;
if (e.Key == Key.Down)
{
PagesListBox.Focus(NavigationMethod.Directional);
if (PagesListBox.SelectedIndex < 0)
PagesListBox.SelectedIndex = 0;
else if (PagesListBox.SelectedIndex < PagesListBox.ItemCount)
if (PagesListBox.SelectedIndex < PagesListBox.ItemCount - 1)
PagesListBox.SelectedIndex++;
else
PagesListBox.SelectedIndex = 0;
e.Handled = true;
}
else if (e.Key == Key.Up)
{
PagesListBox.Focus(NavigationMethod.Directional);
if (PagesListBox.SelectedIndex > 0)
PagesListBox.SelectedIndex--;
else
PagesListBox.SelectedIndex = PagesListBox.ItemCount - 1;
e.Handled = true;
}

View File

@@ -32,14 +32,28 @@ namespace SourceGit.Views
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Down && WorkspaceListBox.ItemCount > 0)
if (WorkspaceListBox.ItemCount == 0)
return;
if (e.Key == Key.Down)
{
WorkspaceListBox.Focus(NavigationMethod.Directional);
if (WorkspaceListBox.SelectedIndex < 0)
WorkspaceListBox.SelectedIndex = 0;
else if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount)
if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount - 1)
WorkspaceListBox.SelectedIndex++;
else
WorkspaceListBox.SelectedIndex = 0;
e.Handled = true;
}
else if (e.Key == Key.Up)
{
WorkspaceListBox.Focus(NavigationMethod.Directional);
if (WorkspaceListBox.SelectedIndex > 0)
WorkspaceListBox.SelectedIndex--;
else
WorkspaceListBox.SelectedIndex = WorkspaceListBox.ItemCount - 1;
e.Handled = true;
}