From dc937485e92e2e2eae79d24bed29a7ffdca372f5 Mon Sep 17 00:00:00 2001 From: Tim Date: Fri, 28 Jan 2022 20:52:23 +0100 Subject: [PATCH 1/2] Invert delta if [SHIFT] is pressed --- src/Avalonia.Input/MouseDevice.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Avalonia.Input/MouseDevice.cs b/src/Avalonia.Input/MouseDevice.cs index 34d2038d661..0e1e460427b 100644 --- a/src/Avalonia.Input/MouseDevice.cs +++ b/src/Avalonia.Input/MouseDevice.cs @@ -334,6 +334,11 @@ private bool MouseWheel(IMouseDevice device, ulong timestamp, IInputRoot root, P var hit = HitTest(root, p); var source = GetSource(hit); + if (inputModifiers == KeyModifiers.Shift) + { + delta = new Vector(delta.Y, delta.X); + } + if (source is not null) { var e = new PointerWheelEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta); From c1e101f491b6153bddfd76920563fe160ef00c9f Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 3 Feb 2022 19:15:46 +0100 Subject: [PATCH 2/2] Perform check if the scroll should be changed on shift key. This may variy by platform, so we need an additional check. --- src/Avalonia.Input/MouseDevice.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Input/MouseDevice.cs b/src/Avalonia.Input/MouseDevice.cs index 0e1e460427b..a17f31498e7 100644 --- a/src/Avalonia.Input/MouseDevice.cs +++ b/src/Avalonia.Input/MouseDevice.cs @@ -5,6 +5,7 @@ using Avalonia.Input.Raw; using Avalonia.Interactivity; using Avalonia.Platform; +using Avalonia.Utilities; using Avalonia.VisualTree; namespace Avalonia.Input @@ -334,7 +335,9 @@ private bool MouseWheel(IMouseDevice device, ulong timestamp, IInputRoot root, P var hit = HitTest(root, p); var source = GetSource(hit); - if (inputModifiers == KeyModifiers.Shift) + // KeyModifiers.Shift should scroll in horizontal direction. This does not work on every platform. + // If Shift-Key is pressed and X is close to 0 we swap the Vector. + if (inputModifiers == KeyModifiers.Shift && MathUtilities.IsZero(delta.X)) { delta = new Vector(delta.Y, delta.X); }