Skip to content

Commit

Permalink
Add method to cancel currently ongoing gesture on a pointer (#13351)
Browse files Browse the repository at this point in the history
* add method to cancel currently ongoing gesture on a pointer

* skip gesture recognition for pointer capture session, revert cancel gesture changes
  • Loading branch information
emmauss committed Oct 26, 2023
1 parent c7e9651 commit fcea345
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Avalonia.Base/Input/Pointer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public void Capture(IInputElement? control)

if (Captured != null)
CaptureGestureRecognizer(null);

if(Captured == null && CapturedGestureRecognizer == null)
{
IsGestureRecognitionSkipped = false;
}
}

static IInputElement? GetNextCapture(Visual parent)
Expand All @@ -79,6 +84,8 @@ private void OnCaptureDetached(object? sender, VisualTreeAttachmentEventArgs e)
/// </summary>
internal GestureRecognizer? CapturedGestureRecognizer { get; private set; }

public bool IsGestureRecognitionSkipped { get; set; }

public void Dispose()
{
Capture(null);
Expand Down
13 changes: 12 additions & 1 deletion src/Avalonia.Base/Input/PointerEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,18 @@ public class PointerEventArgs : RoutedEventArgs
/// </summary>
public ulong Timestamp { get; }

internal bool IsGestureRecognitionSkipped { get; private set; }
internal bool IsGestureRecognitionSkipped
{
get
{
return (Pointer as Pointer)?.IsGestureRecognitionSkipped ?? false;
}
private set
{
if (Pointer is Pointer pointer)
pointer.IsGestureRecognitionSkipped = true;
}
}

/// <summary>
/// Gets a value that indicates which key modifiers were active at the time that the pointer event was initiated.
Expand Down

0 comments on commit fcea345

Please sign in to comment.