mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-05 02:36:19 +02:00
CmdPal: Arrow keys move logical grid pages (#43870)
<!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist - [X] Closes: #41939 <!-- - [ ] Closes: #yyy (add separate lines for additional resolved issues) --> - [X] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [ ] **Tests:** Added/updated and all pass - [ ] **Localization:** All end-user-facing strings can be localized - [ ] **Dev docs:** Added/updated - [ ] **New binaries:** Added on the required places - [ ] [JSON for signing](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ESRPSigning_core.json) for new binaries - [ ] [WXS for installer](https://github.com/microsoft/PowerToys/blob/main/installer/PowerToysSetup/Product.wxs) for new binaries and localization folder - [ ] [YML for CI pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/ci/templates/build-powertoys-steps.yml) for new test projects - [ ] [YML for signed pipeline](https://github.com/microsoft/PowerToys/blob/main/.pipelines/release.yml) - [ ] **Documentation updated:** If checked, please file a pull request on [our docs repo](https://github.com/MicrosoftDocs/windows-uwp/tree/docs/hub/powertoys) and link it here: #xxx <!-- Provide a more detailed description of the PR, other things fixed, or any additional comments/features here --> ## Detailed Description of the Pull Request / Additional comments <!-- Describe how you validated the behavior. Add automated tests wherever possible, but list manual validation steps taken as well --> ## Validation Steps Performed Before  After  I noticed the double "active" line around the items when the ListPage is focused. I was unable to find where that is defined. Ideally, the black-border would go away. I tested with AOT turned on. The behavior accounts for suggestions. If the SearchBar is focused and there is a suggestion, right-arrow will [continue] to complete the suggestion.
This commit is contained in:
@@ -208,21 +208,32 @@ public sealed partial class SearchBar : UserControl,
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == VirtualKey.Left)
|
||||
{
|
||||
// Check if we're in a grid view, and if so, send grid navigation command
|
||||
var isGridView = CurrentPageViewModel is ListViewModel { IsGridView: true };
|
||||
|
||||
// Special handling is required if we're in grid view.
|
||||
if (isGridView)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<NavigateLeftCommand>();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
else if (e.Key == VirtualKey.Right)
|
||||
{
|
||||
// Check if the "replace search text with suggestion" feature from 0.4-0.5 is enabled.
|
||||
// If it isn't, then only use the suggestion when the caret is at the end of the input.
|
||||
if (!IsTextToSuggestEnabled)
|
||||
{
|
||||
if (_textToSuggest != null &&
|
||||
if (!string.IsNullOrEmpty(_textToSuggest) &&
|
||||
FilterBox.SelectionStart == FilterBox.Text.Length)
|
||||
{
|
||||
FilterBox.Text = _textToSuggest;
|
||||
FilterBox.Select(_textToSuggest.Length, 0);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Here, we're using the "replace search text with suggestion" feature.
|
||||
@@ -232,6 +243,20 @@ public sealed partial class SearchBar : UserControl,
|
||||
_lastText = null;
|
||||
DoFilterBoxUpdate();
|
||||
}
|
||||
|
||||
// Wouldn't want to perform text completion *and* move the selected item, so only perform this if text suggestion wasn't performed.
|
||||
if (!e.Handled)
|
||||
{
|
||||
// Check if we're in a grid view, and if so, send grid navigation command
|
||||
var isGridView = CurrentPageViewModel is ListViewModel { IsGridView: true };
|
||||
|
||||
// Special handling is required if we're in grid view.
|
||||
if (isGridView)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<NavigateRightCommand>();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.Key == VirtualKey.Down)
|
||||
{
|
||||
@@ -274,6 +299,8 @@ public sealed partial class SearchBar : UserControl,
|
||||
|
||||
e.Key == VirtualKey.Up ||
|
||||
e.Key == VirtualKey.Down ||
|
||||
e.Key == VirtualKey.Left ||
|
||||
e.Key == VirtualKey.Right ||
|
||||
|
||||
e.Key == VirtualKey.RightMenu ||
|
||||
e.Key == VirtualKey.LeftMenu ||
|
||||
|
||||
Reference in New Issue
Block a user