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

add PointerDeviceKind to ScaleStartDetails #165096

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

yakagami
Copy link
Contributor

@yakagami yakagami commented Mar 13, 2025

Adds the PointerDeviceKind of the scale start event to ScaleStartDetails, which is currently missing.

This is a bug according to #115061. Additionally, according to the docs:

Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer.

See also #135936 for similar issues and the PRs fixing them.

If multiple pointers are contacting the screen at scale start, then the PointerDeviceKind of the first pointer is used. In practice this should be good enough as I don't know of any UI that expects you to use two different pointer kinds at the same time. However, if this is an issue, we could either give a list of pointers with their kinds or a set of all active PointerDeviceKinds. I don't think this is necessary though.

Closes #115061.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: gestures flutter/packages/flutter/gestures repository. labels Mar 13, 2025
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

Looks good except for a small docs change. Thanks for jumping in and making this change. I'm sure a lot of people have struggled with not having this value over the years when someone just needed to add it.

Comment on lines 138 to 140
/// The kind of the device that initiated the event. If multiple pointers are
/// touching the screen, the kind of the pointer device that first initiated
/// the event is used.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@yakagami
Copy link
Contributor Author

I'm sure a lot of people have struggled with not having this value over the years when someone just needed to add it.

Yeah, I was going though the f: gestures issues and noticed I would actually benefit from this myself for my package (https://pub.dev/packages/zoom_view). Right now I use a Listner to get the device kind. The specific reason I need it is because for trackpads you need to disambiguate scaling from panning differently than other pointers. With other pointers you can just check that pointerCount == 1 which is a pan and pointerCount == 2 is a scale. This doesn't work with trackpads because you pan with two fingers on a trackpad. #13102 is related here. I've been thinking if there was a way for the framework to handle that natively and might make another pull request for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: gestures flutter/packages/flutter/gestures repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to use scale gesture recognizer instead of pan recognizer
2 participants