Browse Source

prevent gesture recognition when gesture is captured (#13323)

pull/13677/head
Emmanuel Hansen 3 years ago
committed by GitHub
parent
commit
0bea382d44
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      src/Avalonia.Base/Input/GestureRecognizers/GestureRecognizer.cs
  2. 1
      src/Avalonia.Base/Input/GestureRecognizers/PullGestureRecognizer.cs
  3. 2
      src/Avalonia.Base/Input/GestureRecognizers/ScrollGestureRecognizer.cs

9
src/Avalonia.Base/Input/GestureRecognizers/GestureRecognizer.cs

@ -2,6 +2,7 @@
{
public abstract class GestureRecognizer : StyledElement
{
private PointerEventArgs? _currentPointerEventArgs;
protected internal IInputElement? Target { get; internal set; }
protected abstract void PointerPressed(PointerPressedEventArgs e);
@ -11,17 +12,23 @@
internal void PointerPressedInternal(PointerPressedEventArgs e)
{
_currentPointerEventArgs = e;
PointerPressed(e);
_currentPointerEventArgs = null;
}
internal void PointerReleasedInternal(PointerReleasedEventArgs e)
{
_currentPointerEventArgs = e;
PointerReleased(e);
_currentPointerEventArgs = null;
}
internal void PointerMovedInternal(PointerEventArgs e)
{
_currentPointerEventArgs = e;
PointerMoved(e);
_currentPointerEventArgs = null;
}
internal void PointerCaptureLostInternal(IPointer pointer)
@ -32,6 +39,8 @@
protected void Capture(IPointer pointer)
{
(pointer as Pointer)?.CaptureGestureRecognizer(this);
_currentPointerEventArgs?.PreventGestureRecognition();
}
}
}

1
src/Avalonia.Base/Input/GestureRecognizers/PullGestureRecognizer.cs

@ -44,7 +44,6 @@ namespace Avalonia.Input
{
var currentPosition = e.GetPosition(visual);
Capture(e.Pointer);
e.PreventGestureRecognition();
Vector delta = default;
switch (PullDirection)

2
src/Avalonia.Base/Input/GestureRecognizers/ScrollGestureRecognizer.cs

@ -124,8 +124,6 @@ namespace Avalonia.Input.GestureRecognizers
_trackedRootPoint.Y - (_trackedRootPoint.Y >= rootPoint.Y ? ScrollStartDistance : -ScrollStartDistance));
Capture(e.Pointer);
e.PreventGestureRecognition();
}
}

Loading…
Cancel
Save