Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#7520 from timunie/fix/ScrollViewerShift…
Browse files Browse the repository at this point in the history
…AndPointerWheel

Fix [Shift] + [PointerWheel] should scroll horizontally
  • Loading branch information
maxkatz6 authored and danwalmsley committed Feb 21, 2022
1 parent 2c53e06 commit 039fa5b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Avalonia.Input/MouseDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Avalonia.Input.Raw;
using Avalonia.Interactivity;
using Avalonia.Platform;
using Avalonia.Utilities;
using Avalonia.VisualTree;

namespace Avalonia.Input
Expand Down Expand Up @@ -325,6 +326,13 @@ private bool MouseWheel(IMouseDevice device, ulong timestamp, IInputRoot root, P
var hit = HitTest(root, p);
var source = GetSource(hit);

// 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);
}

if (source is not null)
{
var e = new PointerWheelEventArgs(source, _pointer, root, p, timestamp, props, inputModifiers, delta);
Expand Down

0 comments on commit 039fa5b

Please sign in to comment.