-
Notifications
You must be signed in to change notification settings - Fork 29.7k
SelectionArea cursor should only change when over text #131640
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
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.
Nit: I wonder if we should move some of the documentation from getBoxesForSelection to getBoxesForRange and add a mention to each other in the docs.
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.
done
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.
consider using macro template to share document between these two methods
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.
done
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.
Why is this Center needed?
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.
add center so when add point : await gesture.addPointer(location: tester.getCenter(find.byType(Text)));
the center of the text widget is within the actual text.
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.
Can you explain the change to this test, I don't fully understand. Thank you!
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 is to make the text as big as the text widget, so the hittest will hit the textspan for these tests.
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.
Is the original test no longer valid? otherwise, we should create a new test
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.
yes, the original test is no longer valid
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.
weird it is declared as Object? it is probably a mistake I think
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.
done
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.
If we really want to be certain, this range should be coming from the span, since this is where the hittest will be sent to
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.
There doesn't seem to be an existing api to get the range of a span in text painter.
I think boxes for (textPosition.offset - 1, textPosition.offset +1) should cover all cases.
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.
If there is no easy way to do that, I am fine with using textPosition.offset +-1
Also this can be
max(0, textPosition.offset - 1)
min(_textPainter.text.length, textPosition.offset + 1)
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.
can you write a test that selectable textspan with recognizer will still show SystemMouseCursors.click when hover over the recognizer?
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.
done
Renzo-Olivares
left a comment
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.
LGTM after google testing passes, it looks like some related tests are failing.
chunhtai
left a comment
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.
LGTM, just some nits
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.
consider using macro template to share document between these two methods
Co-authored-by: chunhtai <[email protected]>
Co-authored-by: chunhtai <[email protected]>
|
auto label is removed for flutter/flutter, pr: 131640, due to - The status or check suite ci.yaml validation has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
auto label is removed for flutter/flutter, pr: 131640, due to - The status or check suite Google testing has failed. Please fix the issues identified (or deflake) before re-applying this label. |
| result.add(HitTestEntry(span)); | ||
| return true; | ||
| if (_positionIsWithinText(position: position, textPosition: textPosition)) { | ||
| final InlineSpan? span = _textPainter.text!.getSpanForPosition(textPosition); |
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.
The reason span was typed Object? was to avoid the down-casting below (i.e. span! as HitTestTarget).
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.
Makes sense, please also add a comment on this line to explain this.
| math.max(0, textPosition.offset - 1), | ||
| math.min(_textPainter.plainText.length, textPosition.offset + 1), | ||
| ); | ||
| return boxes.where((ui.TextBox box) => box.toRect().contains(position)).isNotEmpty; |
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.
boxes.any so it stops when it finds a box.
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 suspect this is going to be slow if the method gets called frequently. There's a new Skia API that will allow us to do this correctly and efficiently. Unfortunately it's not exposed in text painter yet. If this fix is not needed immediately would it be ok to wait until the new APIs are available?
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 is not needed immediately, I can close this pr and wait for the new APIs.
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.
@LongCatIsLooong What is the timeline on the Skia API? I have a need for this in Linkify (#125927). I filed #131435 and verified that this PR did fix the issue for me locally.
Even though I'm excited for this to fix my Linkify problem, it's not really super urgent. Linkify is not yet ready to merge, and merging it without this fix wouldn't even be terrible. I just want to make sure it's not going to be months or something for the Skia change.
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.
The skia API is already available it just needs to be exposed (but the HTML renderer needs a separate implementation). I'll start working on that once the rounding thing is removed.
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.
Sounds good, thanks!
fixes: #104594
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.