Browse Source

Forward pointer wheel event from scrollbar to scrollviewer (#16398)

* forward pointer wheel event from scrollbar to scrollviewer

* raise cloned pointer wheel event in scrollbar

---------

Co-authored-by: Max Katz <maxkatz6@outlook.com>
pull/16575/head
Emmanuel Hansen 2 years ago
committed by GitHub
parent
commit
4c2d9fcda7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 21
      src/Avalonia.Controls/Primitives/ScrollBar.cs

21
src/Avalonia.Controls/Primitives/ScrollBar.cs

@ -257,6 +257,27 @@ namespace Avalonia.Controls.Primitives
}
}
protected override void OnPointerWheelChanged(PointerWheelEventArgs e)
{
base.OnPointerWheelChanged(e);
// We need to handle pointer wheel event to allow scrolling with the pointer wheel. So we raise the event on the scrollviewer's presenter
if (!e.Handled && _owner?.Presenter is { } presenter && VisualRoot is Visual root)
{
e.Handled = true;
e = new PointerWheelEventArgs(
this,
e.Pointer,
root,
e.GetPosition(root),
e.Timestamp,
new PointerPointProperties((RawInputModifiers)e.KeyModifiers, PointerUpdateKind.Other),
e.KeyModifiers,
e.Delta);
presenter.RaiseEvent(e);
}
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);

Loading…
Cancel
Save