-
Notifications
You must be signed in to change notification settings - Fork 29.2k
Adds support for floating cursor #24761
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
You mentioned #20693, which to me is a fundamentally more serious issue than #17030, but your various descriptions only seem to fix the latter; does this in fact fix the issue in the former as well? (The latter issue your description states you have fixed involves a relatively rarely-used feature involving force touch on a keyboard that was only introduced in recent versions of iOS, while the former issue that you mention is entirely different: it involves the primary method of moving the cursor which has existed forever, I believe back well into when iOS was called iPhoneOS ;P--where a tap and hold on text lets you move the cursor--which supposedly is causing the text to be selected in Flutter.) (cc: @tvolkert) |
@saurik If you have concerns or more details for the bugs please note them in the respective issues. This isn't the correct place for a discussion. |
@saurik With this patch, you can move the cursor while dragging in a text field while in the force touch mode, but upon closer inspection, it looks like that bug is for non force touch based dragging? If that is the case it doesn't fix that bug. |
@@ -701,6 +706,23 @@ class RenderEditable extends RenderBox { | |||
markNeedsPaint(); | |||
} | |||
|
|||
/// The padding applied to text field. Used to determine the bounds when | |||
/// moving the floating cursor. |
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.
Not sure why this is necessary from reading this. Is it not used for non-floating cursor?
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 on iOS, the floating cursor can be rendered right up the edge of the text field on the top and bottom, and half way to the edge on the right and left. This is not used for a non floating cursor. I'd by happy to show you where it takes function tomorrow!
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 see now. Maybe it's just a name tweak. Maybe floatingCursorAddedMargin or floatingCursorRectExpansion or some such.
} | ||
|
||
void _paintFloatingCaret(Canvas canvas, Offset effectiveOffset) { | ||
assert(_textLayoutLastWidth == constraints.maxWidth); |
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.
assert the state
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.
not sure what state you mean?
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.
Ah right. Perhaps check _floatingCursorOn then. In general, the more instance variables there are that needs manual resetting, better it is to assert all assumptions and make things fail as early as possible if things aren't in the right state.
I've just checked this out (the engine requires some typos fixing to compile/run) and given it a good test and it's not quite working properly, the drawing of the "floating" cursor and caret is working find until the "end" event. Expected: Actual: |
@mikezs . You need to check out the engine commit as well, and run with --local-engine to make this work. Also, I changed some of the names around in the most recent commit and have not yet tested, so check out #e0b973b in flutter/flutter and #954e796 in flutter/engine (flutter/engine#6945) if you want to test this. |
I have to compile the engine to test it because of the message channels passing the state. I assume it wouldn't work at all without doing that. I've checked out the other commits and recompiled for iOS, the host and flutter library and the only difference is the animating back to the original position. Looking pretty good! |
@mikezs Glad you got it working, and you're right about the animation! Thanks for catching that! |
@mikezs Things are working again in the most recent commit, and I just pushed a change which has the animation if you want that as well! |
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
@@ -701,6 +706,23 @@ class RenderEditable extends RenderBox { | |||
markNeedsPaint(); | |||
} | |||
|
|||
/// The padding applied to text field. Used to determine the bounds when | |||
/// moving the floating cursor. |
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 see now. Maybe it's just a name tweak. Maybe floatingCursorAddedMargin or floatingCursorRectExpansion or some such.
This reverts commit 46878d8.
This reverts commit 46878d8.
Adds framework support for the floating cursor for text editing on iOS. It can be triggered by either a force press on the keyboard or (on iOS 12) by long pressing the spacebar. Fixes #17030 (#5445).