-
Notifications
You must be signed in to change notification settings - Fork 28.6k
[New Feature]Support mouse wheel event on the scrollbar widget #109659
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
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
if ((scrollbarPainter.hitTest(event.localPosition) ?? false) && | ||
_cachedController != null && | ||
_cachedController!.hasClients && | ||
!_thumbDragging) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_thumbDragging
is intend to do not break
https://github.com/Piinks/flutter/blob/f574242ca5df1bf2ad1bd0000f75e6a35ed25a92/packages/flutter/test/material/scrollbar_test.dart#L1371-L1374
But I test on the window native platform, it can pointer scroll during drag. WDYT @Piinks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to look at this more, but it sounds like it might be different behavior on different platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I was out sick.
I think that test was added to ensure we did not regress on a crash wayy back when CupertinoScrollbar implemented its own scrollbar drag gesture. The way it did this was to create a drag event on the scrollable, and so it would crash if more than one drag was happening simultaneously. Since the scrollbar gestures were refactored and they do not create a drag event anymore, it is probably safe to remove that test and allow thumb dragging. Since this is a new feature, we can iterate on it as we compare it to other platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just test this behavior(whether can scroll by mouse touch(mac) or mouse wheel when dragging the bar) on Mac and Windows platforms, here is the result,
1, Mac + Native APP(Finder), can not scroll use touchpad or mouse touch when the bar is dragging.
2, Mac + chrome/safari, it can scroll.
3, Windows + web, it can scroll.
4, Windows + Native APP(File Explorer), can not scroll when the pointer hovers on the bar but can scroll when the pointer does not hover on the bar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am planning to allow this behavior only on the web. WDYT? @Piinks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for researching this so fully!
I am planning to allow this behavior only on the web
I think that makes sense. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will continue to update after #112434 is checked in, they may have conflicts.
@@ -1755,14 +1756,15 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv | |||
@mustCallSuper | |||
void handleThumbPressStart(Offset localPosition) { | |||
assert(_debugCheckHasValidScrollPosition()); | |||
_currentController = widget.controller ?? PrimaryScrollController.of(context); | |||
_cachedController = _effectiveScrollController; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love this, very nice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Piinks Hi, this is ready for review now and is not urgent, just put it in your queue.
if ((scrollbarPainter.hitTest(event.localPosition) ?? false) && | ||
_cachedController != null && | ||
_cachedController!.hasClients && | ||
!_thumbDragging) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I was out sick.
I think that test was added to ensure we did not regress on a crash wayy back when CupertinoScrollbar implemented its own scrollbar drag gesture. The way it did this was to create a drag event on the scrollable, and so it would crash if more than one drag was happening simultaneously. Since the scrollbar gestures were refactored and they do not create a drag event anymore, it is probably safe to remove that test and allow thumb dragging. Since this is a new feature, we can iterate on it as we compare it to other platforms.
@@ -1806,7 +1810,11 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv | |||
@mustCallSuper | |||
void handleThumbPressUpdate(Offset localPosition) { | |||
assert(_debugCheckHasValidScrollPosition()); | |||
final ScrollPosition position = _currentController!.position; | |||
if (_lastDragUpdateOffset == localPosition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will frequently be called when press and hold. There are benefits to short-circuiting it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
if ((scrollbarPainter.hitTest(event.localPosition) ?? false) && | ||
_cachedController != null && | ||
_cachedController!.hasClients && | ||
(!_thumbDragging || kIsWeb)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referring to the behavior of the native platforms, we only allow pointer scroll during thumb dragging on the web.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are some merge conflicts here, can you take a look?
@@ -1806,7 +1810,11 @@ class RawScrollbarState<T extends RawScrollbar> extends State<T> with TickerProv | |||
@mustCallSuper | |||
void handleThumbPressUpdate(Offset localPosition) { | |||
assert(_debugCheckHasValidScrollPosition()); | |||
final ScrollPosition position = _currentController!.position; | |||
if (_lastDragUpdateOffset == localPosition) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
key: _scrollbarPainterKey, | ||
foregroundPainter: scrollbarPainter, | ||
child: RepaintBoundary(child: widget.child), | ||
child: Listener( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this took me a minute because I thought, why can't we approach this through hit testing? Of course you already had an answer for me: #99328 😜
I don't love having so many handlers and listeners here, like MouseRegion (for hovering), Listener (for pointer scrolling), NotificationListeners (for scrolling and scroll metrics), but they do seem necessary to be able to match all of the various behaviors we see on different platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auto label is removed for flutter/flutter, pr: 109659, due to - The status or check suite Mac tool_tests_commands has failed. Please fix the issues identified (or deflake) before re-applying this label. |
Hrm, can you rebase with master to see if that resolves this failing test? It is unrelated to your PR, but rerunning it still fails so it may be something else on your branch. Sorry for the inconvenience |
Could someone restart the G test: ) |
On it! It is having issues this week. |
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
…er#109659) * rebase master and add a test * fix the test * fix the test * fix the test
…er#109659) * rebase master and add a test * fix the test * fix the test * fix the test
* 77d6ecb 805b145d7 [web] Improve line breaker test exceptions (flutter/engine#37244) (flutter/flutter#114688) * 5233fd9 Roll Plugins from 5c11747 to a279b9d (6 revisions) (flutter/flutter#114689) * e1166e4 287a3ab59 Roll Skia from c901cb6ae66f to 1272b520c082 (1 revision) (flutter/engine#37314) (flutter/flutter#114691) * 48457d7 WidgetController.startGesture trackpad support (flutter/flutter#114631) * c1d2b85 Change some required nullable parameters in tool to non-null (flutter/flutter#114115) * cfb2f15 Roll Flutter Engine from 287a3ab59269 to e947833ceb5b (2 revisions) (flutter/flutter#114696) * 80bf355 Support keyboard selection in SelectabledRegion (flutter/flutter#112584) * be83c98 5117e858e Fix typo in overlay platform view iOS test (flutter/engine#37262) (flutter/flutter#114705) * 6ea01e6 Roll Flutter Engine from 5117e858ed1e to 6950689ed775 (3 revisions) (flutter/flutter#114710) * b187bc4 Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (flutter/flutter#114637) * 01507ba Revert "Switch the way we retrieve the vm_service_port from /hub to iquery, on device. (#114637)" (flutter/flutter#114715) * 91a56cf roll packages (flutter/flutter#114366) * d68af26 Roll Flutter Engine from 6950689ed775 to 0933ca485a07 (3 revisions) (flutter/flutter#114714) * 4fd0a92 Remove auto_cleanup of xcode caches. (flutter/flutter#114719) * 96f9ca8 Roll Flutter Engine from 0933ca485a07 to 28e1ea0cc5b1 (4 revisions) (flutter/flutter#114720) * 1aada6f [New Feature]Support mouse wheel event on the scrollbar widget (flutter/flutter#109659) * 6265610 Roll Flutter Engine from 28e1ea0cc5b1 to ba390f2a7b7d (3 revisions) (flutter/flutter#114728) * 140a57e Roll Flutter Engine from ba390f2a7b7d to 223a485ceb02 (3 revisions) (flutter/flutter#114732) * 06ded49 Roll Flutter Engine from 223a485ceb02 to cf56eb5565e2 (3 revisions) (flutter/flutter#114735) * e0e7027 9c45b0ebe Roll Fuchsia Mac SDK from jAKH68TYoKUA5HNS2... to Ua8Jtf8Zka9uxIVdl... (flutter/engine#37345) (flutter/flutter#114746)
Fixes #109519