Skip to content

Desktop edge scrolling - #93170

Merged
fluttergithubbot merged 20 commits into
flutter:masterfrom
justinmc:edge-scrolling-desktop
Nov 16, 2021
Merged

fluttergithubbot merged 20 commits into
flutter:masterfrom
justinmc:edge-scrolling-desktop

Conversation

@justinmc

@justinmc justinmc commented Nov 5, 2021 •

Copy link
Copy Markdown
Contributor

When selection moves on desktop, the field will now scroll to view the scroll extent, like it already does on mobile.

edge_mac_2

TODO:

  • Make sure horizontal edge scrolling works.
  • Make sure this works on Windows.
  • Tests.

Fixes #32344
Fixes #59141

@justinmc justinmc self-assigned this Nov 5, 2021
@flutter-dashboard flutter-dashboard Bot added a: text input Entering text in a text field or keyboard related problems p: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages framework flutter/packages/flutter repository. See also f: labels. labels Nov 5, 2021
@google-cla google-cla Bot added the cla: yes label Nov 5, 2021
@justinmc
justinmc force-pushed the edge-scrolling-desktop branch from b47b649 to e309a02 Compare November 8, 2021 20:50
@justinmc

justinmc commented Nov 9, 2021

Copy link
Copy Markdown
Contributor Author

@mdebbar Is this old TODO of yours actually fixed?

// TODO(mdebbar): Support dragging in any direction (for multiline text).
// https://github.com/flutter/flutter/issues/28676

I ran into a strange problem where vertical mouse dragging wasn't being detected properly in a test. I'm wondering if there's anything unimplemented there that could be causing it, or if that TODO should be removed.

@mdebbar

mdebbar commented Nov 9, 2021

Copy link
Copy Markdown
Contributor

@justinmc if you look at that code, it's only using a HorizontalDragGestureRecognizer which doesn't detect vertical dragging. At that time, vertical dragging was used for scrolling (even on web, because there was no scroll bars yet). But now I think that's not the case anymore. Maybe we should use PanGestureRecognizer?

@justinmc

Copy link
Copy Markdown
Contributor Author

Sounds good, thanks for the info. I'll make a quick attempt at using PanGestureRecognizer and see if that fixes the strange missing vertical drag component that I saw in the test. If it seems complicated, I'll save it for another PR.

@justinmc
justinmc force-pushed the edge-scrolling-desktop branch from 0515541 to 904d164 Compare November 10, 2021 19:27
@justinmc
justinmc force-pushed the edge-scrolling-desktop branch from aeb96e8 to ccad131 Compare November 10, 2021 21:55
DragStartDetails? _lastDragStartDetails;
DragUpdateDetails? _lastDragUpdateDetails;
Timer? _dragUpdateThrottleTimer;
bool _isMouseDragging = false;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

HorizontalDragGestureRecognizer allows you to specify the type of pointer to accept, but now that we've switched to PanGestureRecognizer, which doesn't support that, we have to manually make sure we only listen to mouse drags.

@LongCatIsLooong LongCatIsLooong Nov 11, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would it be possible to add that to the existing PanGestureRecognizer or use a private subclass of PanGestureRecognizer here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Great idea, looks like it's actually only a 2 line change to add it to PanGesureRecognizer because the super class already supports it.

@justinmc
justinmc marked this pull request as ready for review November 11, 2021 01:07
@justinmc

Copy link
Copy Markdown
Contributor Author

@mdebbar Switching to PanGestureRecognizer worked without too much tweaking, and it fixed my test! I've replaced it here in this PR and removed your TODO.

switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
case TargetPlatform.macOS:
if (cause == SelectionChangedCause.longPress

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just curious what does a long-press do on iOS and macOS? Is it the force press floating cursor that makes them different?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup this handles the thing where you force press and then drag the cursor.

PointerDeviceKind? kind,
}) : super(
debugOwner: debugOwner,
kind: kind,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

kind is deprecated I think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah I missed that, thanks. I'll do the same thing but with supportedDevices as the deprecation message suggests.

@LongCatIsLooong LongCatIsLooong left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. This should also close #28676 (the TODO issue) right?

@justinmc

Copy link
Copy Markdown
Contributor Author

@LongCatIsLooong That one is already closed, but I guess the TODO was missed.

@fluttergithubbot
fluttergithubbot merged commit 297a7c7 into flutter:master Nov 16, 2021
@justinmc
justinmc deleted the edge-scrolling-desktop branch November 16, 2021 23:05
@justinmc

Copy link
Copy Markdown
Contributor Author

Adding the cherry pick tag after discussing with @mariamhas, if we're still doing cherry picks for 2.8. Shouldn't be a high risk of regressions.

WizzXu pushed a commit to WizzXu/flutter that referenced this pull request Nov 19, 2021
@devoncarew

Copy link
Copy Markdown
Contributor

@justinmc and @HansMuller - when was this regression introduced? What's the impact if we don't take it for this hotfix? We should carefully weigh taking it now (the week right before the release) w/ delaying until a batch of fixes after the release.

@justinmc

Copy link
Copy Markdown
Contributor Author

I'm ok with skipping this. The behavior without it is fairly bad, but it's actually not a regression. Also there were previously a few goldens issues with this. Probably best to let it be released normally if @mariamhas is alright with that.

@mariamhas

mariamhas commented Nov 30, 2021 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. p: cupertino_ui cupertino_ui package in flutter/packages p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't select text with mouse once it's longer than the text field Implement edge scrolling for text selection in Text/TextField

6 participants