Skip to content

Commit 0c9e628

Browse files
committed
enhance: allow to use arrow up/down to select workspace/tab after switcher popups (#1711)
Signed-off-by: leo <[email protected]>
1 parent 7c0f280 commit 0c9e628

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

src/Views/LauncherPageSwitcher.axaml.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,28 @@ private void OnItemTapped(object sender, TappedEventArgs e)
3232

3333
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
3434
{
35-
if (e.Key == Key.Down && PagesListBox.ItemCount > 0)
35+
if (PagesListBox.ItemCount == 0)
36+
return;
37+
38+
if (e.Key == Key.Down)
3639
{
3740
PagesListBox.Focus(NavigationMethod.Directional);
3841

39-
if (PagesListBox.SelectedIndex < 0)
40-
PagesListBox.SelectedIndex = 0;
41-
else if (PagesListBox.SelectedIndex < PagesListBox.ItemCount)
42+
if (PagesListBox.SelectedIndex < PagesListBox.ItemCount - 1)
4243
PagesListBox.SelectedIndex++;
44+
else
45+
PagesListBox.SelectedIndex = 0;
46+
47+
e.Handled = true;
48+
}
49+
else if (e.Key == Key.Up)
50+
{
51+
PagesListBox.Focus(NavigationMethod.Directional);
52+
53+
if (PagesListBox.SelectedIndex > 0)
54+
PagesListBox.SelectedIndex--;
55+
else
56+
PagesListBox.SelectedIndex = PagesListBox.ItemCount - 1;
4357

4458
e.Handled = true;
4559
}

src/Views/WorkspaceSwitcher.axaml.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,28 @@ private void OnItemTapped(object sender, TappedEventArgs e)
3232

3333
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
3434
{
35-
if (e.Key == Key.Down && WorkspaceListBox.ItemCount > 0)
35+
if (WorkspaceListBox.ItemCount == 0)
36+
return;
37+
38+
if (e.Key == Key.Down)
3639
{
3740
WorkspaceListBox.Focus(NavigationMethod.Directional);
3841

39-
if (WorkspaceListBox.SelectedIndex < 0)
40-
WorkspaceListBox.SelectedIndex = 0;
41-
else if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount)
42+
if (WorkspaceListBox.SelectedIndex < WorkspaceListBox.ItemCount - 1)
4243
WorkspaceListBox.SelectedIndex++;
44+
else
45+
WorkspaceListBox.SelectedIndex = 0;
46+
47+
e.Handled = true;
48+
}
49+
else if (e.Key == Key.Up)
50+
{
51+
WorkspaceListBox.Focus(NavigationMethod.Directional);
52+
53+
if (WorkspaceListBox.SelectedIndex > 0)
54+
WorkspaceListBox.SelectedIndex--;
55+
else
56+
WorkspaceListBox.SelectedIndex = WorkspaceListBox.ItemCount - 1;
4357

4458
e.Handled = true;
4559
}

0 commit comments

Comments
 (0)