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 public abstract class GestureRecognizer : StyledElement
{ {
private PointerEventArgs? _currentPointerEventArgs;
protected internal IInputElement? Target { get; internal set; } protected internal IInputElement? Target { get; internal set; }
protected abstract void PointerPressed(PointerPressedEventArgs e); protected abstract void PointerPressed(PointerPressedEventArgs e);
@ -11,17 +12,23 @@
internal void PointerPressedInternal(PointerPressedEventArgs e) internal void PointerPressedInternal(PointerPressedEventArgs e)
{ {
_currentPointerEventArgs = e;
PointerPressed(e); PointerPressed(e);
_currentPointerEventArgs = null;
} }
internal void PointerReleasedInternal(PointerReleasedEventArgs e) internal void PointerReleasedInternal(PointerReleasedEventArgs e)
{ {
_currentPointerEventArgs = e;
PointerReleased(e); PointerReleased(e);
_currentPointerEventArgs = null;
} }
internal void PointerMovedInternal(PointerEventArgs e) internal void PointerMovedInternal(PointerEventArgs e)
{ {
_currentPointerEventArgs = e;
PointerMoved(e); PointerMoved(e);
_currentPointerEventArgs = null;
} }
internal void PointerCaptureLostInternal(IPointer pointer) internal void PointerCaptureLostInternal(IPointer pointer)
@ -32,6 +39,8 @@
protected void Capture(IPointer pointer) protected void Capture(IPointer pointer)
{ {
(pointer as Pointer)?.CaptureGestureRecognizer(this); (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); var currentPosition = e.GetPosition(visual);
Capture(e.Pointer); Capture(e.Pointer);
e.PreventGestureRecognition();
Vector delta = default; Vector delta = default;
switch (PullDirection) 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)); _trackedRootPoint.Y - (_trackedRootPoint.Y >= rootPoint.Y ? ScrollStartDistance : -ScrollStartDistance));
Capture(e.Pointer); Capture(e.Pointer);
e.PreventGestureRecognition();
} }
} }

Loading…
Cancel
Save