[CmdPal] Fix Up/Down keyboard navigation + continuous navigation (#38499)

## Summary of the Pull Request

Fix #38337 and implement continuous navigation like PT Run v1

<!-- Please review the items on the PR checklist before submitting-->
## PR Checklist

- [x] **Closes:** #38337
This commit is contained in:
Davide Giacometti
2025-04-03 13:47:23 +02:00
committed by GitHub
parent d48286a3eb
commit c6776d0d45
2 changed files with 21 additions and 12 deletions

View File

@@ -105,19 +105,8 @@ public sealed partial class SearchBar : UserControl,
var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down); var ctrlPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
var altPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down); var altPressed = InputKeyboardSource.GetKeyStateForCurrentThread(VirtualKey.Menu).HasFlag(CoreVirtualKeyStates.Down);
if (e.Key == VirtualKey.Down)
{
WeakReferenceMessenger.Default.Send<NavigateNextCommand>();
e.Handled = true; if (ctrlPressed && e.Key == VirtualKey.Enter)
}
else if (e.Key == VirtualKey.Up)
{
WeakReferenceMessenger.Default.Send<NavigatePreviousCommand>();
e.Handled = true;
}
else if (ctrlPressed && e.Key == VirtualKey.Enter)
{ {
// ctrl+enter // ctrl+enter
WeakReferenceMessenger.Default.Send<ActivateSecondaryCommandMessage>(); WeakReferenceMessenger.Default.Send<ActivateSecondaryCommandMessage>();
@@ -197,6 +186,18 @@ public sealed partial class SearchBar : UserControl,
_isBackspaceHeld = true; _isBackspaceHeld = true;
} }
} }
else if (e.Key == VirtualKey.Up)
{
WeakReferenceMessenger.Default.Send<NavigatePreviousCommand>();
e.Handled = true;
}
else if (e.Key == VirtualKey.Down)
{
WeakReferenceMessenger.Default.Send<NavigateNextCommand>();
e.Handled = true;
}
} }
private void FilterBox_PreviewKeyUp(object sender, KeyRoutedEventArgs e) private void FilterBox_PreviewKeyUp(object sender, KeyRoutedEventArgs e)

View File

@@ -187,6 +187,10 @@ public sealed partial class ListPage : Page,
{ {
ItemsList.SelectedIndex++; ItemsList.SelectedIndex++;
} }
else
{
ItemsList.SelectedIndex = 0;
}
} }
public void Receive(NavigatePreviousCommand message) public void Receive(NavigatePreviousCommand message)
@@ -195,6 +199,10 @@ public sealed partial class ListPage : Page,
{ {
ItemsList.SelectedIndex--; ItemsList.SelectedIndex--;
} }
else
{
ItemsList.SelectedIndex = ItemsList.Items.Count - 1;
}
} }
public void Receive(ActivateSelectedListItemMessage message) public void Receive(ActivateSelectedListItemMessage message)