From e576ca51c3e3fe5162068bdf3de28cbdfdbf397f Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Wed, 31 Jul 2024 13:44:21 +0300 Subject: [PATCH] fix(pointers): don't respond to multiple mouse button presses at the same time --- .../Xaml/Internal/InputManager.Pointers.Managed.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs b/src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs index 479d1ef7374b..2e7d9914f1d6 100644 --- a/src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs +++ b/src/Uno.UI/UI/Xaml/Internal/InputManager.Pointers.Managed.cs @@ -352,6 +352,12 @@ private void OnPointerExited(Windows.UI.Core.PointerEventArgs args) private void OnPointerPressed(Windows.UI.Core.PointerEventArgs args) { + // If 2+ mouse buttons are pressed, we only respond to the first. + if (args.CurrentPoint.PointerDeviceType == PointerDeviceType.Mouse && _pressedElements.Count != 0) + { + return; + } + if (TryRedirectPointerPress(args)) { return; @@ -387,6 +393,13 @@ private void OnPointerPressed(Windows.UI.Core.PointerEventArgs args) private void OnPointerReleased(Windows.UI.Core.PointerEventArgs args) { + // When multiple mouse buttons are pressed and then released, we only respond to the last OnPointerReleased + // (i.e when no more buttons are still pressed). + if (args.CurrentPoint.PointerDeviceType == PointerDeviceType.Mouse && args.CurrentPoint.IsInContact) + { + return; + } + if (TryRedirectPointerRelease(args)) { return;