mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
CmdPal: Allow mouse X1 button to navigate back (#40517)
## Summary of the Pull Request Enables navigation to the previous page when the mouse X1 (back) button is pressed. This improves user experience for those using multi-button mice, making navigation more intuitive. ## PR Checklist - [x] **Closes:** #40499 - [x] **Communication:** I've discussed this with core contributors already. If the work hasn't been agreed, this work might be rejected - [x] **Tests:** Added/updated and all pass - [x] **Localization:** All end-user-facing strings can be localized - [x] **Dev docs:** nope - [x] **New binaries:** nada - [x] **Documentation updated:** nothing to add ## Detailed Description of the Pull Request / Additional comments ## Validation Steps Performed
This commit is contained in:
1
.github/actions/spell-check/expect.txt
vendored
1
.github/actions/spell-check/expect.txt
vendored
@@ -1932,6 +1932,7 @@ Wubi
|
|||||||
WUX
|
WUX
|
||||||
Wwanpp
|
Wwanpp
|
||||||
XAxis
|
XAxis
|
||||||
|
XButton
|
||||||
xclip
|
xclip
|
||||||
xcopy
|
xcopy
|
||||||
XDeployment
|
XDeployment
|
||||||
|
|||||||
@@ -14,8 +14,10 @@ using Microsoft.CommandPalette.Extensions;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.PowerToys.Telemetry;
|
using Microsoft.PowerToys.Telemetry;
|
||||||
using Microsoft.UI.Dispatching;
|
using Microsoft.UI.Dispatching;
|
||||||
|
using Microsoft.UI.Input;
|
||||||
using Microsoft.UI.Xaml.Controls;
|
using Microsoft.UI.Xaml.Controls;
|
||||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||||
|
using Microsoft.UI.Xaml.Input;
|
||||||
using Microsoft.UI.Xaml.Media.Animation;
|
using Microsoft.UI.Xaml.Media.Animation;
|
||||||
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
|
using DispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue;
|
||||||
|
|
||||||
@@ -79,6 +81,8 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
|||||||
WeakReferenceMessenger.Default.Register<ShowToastMessage>(this);
|
WeakReferenceMessenger.Default.Register<ShowToastMessage>(this);
|
||||||
WeakReferenceMessenger.Default.Register<NavigateToPageMessage>(this);
|
WeakReferenceMessenger.Default.Register<NavigateToPageMessage>(this);
|
||||||
|
|
||||||
|
AddHandler(PointerPressedEvent, new PointerEventHandler(ShellPage_OnPointerPressed), true);
|
||||||
|
|
||||||
RootFrame.Navigate(typeof(LoadingPage), ViewModel);
|
RootFrame.Navigate(typeof(LoadingPage), ViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,4 +446,24 @@ public sealed partial class ShellPage : Microsoft.UI.Xaml.Controls.Page,
|
|||||||
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(commandViewModel.Model));
|
WeakReferenceMessenger.Default.Send<PerformCommandMessage>(new(commandViewModel.Model));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ShellPage_OnPointerPressed(object sender, PointerRoutedEventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var ptr = e.Pointer;
|
||||||
|
if (ptr.PointerDeviceType == PointerDeviceType.Mouse)
|
||||||
|
{
|
||||||
|
var ptrPt = e.GetCurrentPoint(this);
|
||||||
|
if (ptrPt.Properties.IsXButton1Pressed)
|
||||||
|
{
|
||||||
|
WeakReferenceMessenger.Default.Send(new NavigateBackMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.LogError("Error handling mouse button press event", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user