Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make PreventGestureRecognition pointer scope, and not event scope. #13351

Merged
merged 2 commits into from
Oct 27, 2023

Conversation

emmauss
Copy link
Contributor

@emmauss emmauss commented Oct 23, 2023

What does the pull request do?

PreventGestureRecognition now prevents gestures from receiving events from the pointer, until pointer is released.

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

This is a change in behaviour

Obsoletions / Deprecations

Fixed issues

/// The previously captured element. This is set when a <see cref="GestureRecognizer"/> captures
/// the pointer.
/// </summary>
internal IInputElement? PreviousCaptured { get; private set; }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to be careful here to not memory leak anything. Leak test with simulated gestures would be nice as well.

/// element if available. If no gesture is currently started by the pointer, no changes are made.
/// </summary>
/// <param name="pointer">The pointer with the captured gesture</param>
public void CancelCurrentGesture(Pointer pointer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API usage is unclear. Which element one would call this method on?

Copy link
Member

@kekekeks kekekeks Oct 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i. e.

<ScrollViewer> <!-- captured here -->
   <StackPanel>
       <TextBox/>  <-- I assume it's the control that would want to cancel the gesture -->
   </StackPanel>
</ScrollViewer>

On which element should CancelCurrentGesture be called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ScrollViewer, in this case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to know that we actually canceled some active gesture?

I could call that at the root level and the method would walk down the visual tree to find a matching control. Do you think this is really needed or should the caller implement this?

@maxkatz6 maxkatz6 added this pull request to the merge queue Oct 26, 2023
Merged via the queue into master with commit fcea345 Oct 27, 2023
@maxkatz6 maxkatz6 deleted the cancel_gesture branch October 27, 2023 00:13
@emmauss emmauss changed the title Add method to cancel currently ongoing gesture on a pointer Make PreventGestureRecognition pointer scope, and not event scope. Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants