-
Notifications
You must be signed in to change notification settings - Fork 6k
[floating_cursor_selection] a somewhat "design doc" for floating cursor feature #42173
[floating_cursor_selection] a somewhat "design doc" for floating cursor feature #42173
Conversation
| // Floating cursor's "selection" gesture also starts with 1 finger to force press the space bar, | ||
| // so exactly the same functions as the "move gesture" discussed above will be called. When the | ||
| // second finger is pressed, `setSelectedText` will be called, which indicates the beginning of | ||
| // the selection gesture. (This mechanism requires `closestPositionFromPoint` to be implemented, so |
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.
setSelectedText doesn't necessarily mean the beginning of the selection gesture. It will be called during the selection gesture each time the finger moves enough to change the selection
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.
Oh I meant to say when setSelectedText is first time called, we can tell that user started the gesture. But there are also some nuances, such as the distance threshold of the gesture, as you said here. I think i can remove this part.
| // | ||
| // Notice that during the move gesture, the framework only animate the cursor visually. It's only | ||
| // after the gesture is complete, will the framework update the selection to the cursor's | ||
| // new position (with zero selection length). This means during the animation, the selection |
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 wouldn't say the selection is out of sync between framework and engine. It isn't modified in the framework during the move gesture until the end. So you can say the visual is out of sync with the selection state in both framework and engine.
| // so exactly the same functions as the "move gesture" discussed above will be called. When the | ||
| // second finger is pressed, `setSelectedText` will be called, which indicates the beginning of | ||
| // the selection gesture. (This mechanism requires `closestPositionFromPoint` to be implemented, so | ||
| // that UIKit can determine the selected text range based on points.) When the selection is |
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 that UIKit can determine which position in the text is the closest to any arbitrary screen point
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.
How about "so that UIKit can determine which text position is the closest to any arbitrary screen point, hence determine the selected text range based on those points.".
It's definitely used for other features for sure, but I want this to be more specific to this particular feature.
|
Are we intending to land this? @hellohuanlin, there is some feedback to incorporate. |
|
@chinmaygarde yep. will do. |
0d5601a to
c3dc3e3
Compare
LongCatIsLooong
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 with nits thanks for adding this!
| // Floating cursor's "move" gesture takes 1 finger to force press the space bar, and then move the | ||
| // cursor. The process starts with `beginFloatingCursorAtPoint`. When the finger is moved, | ||
| // `updateFloatingCursorAtPoint` will be called. When the finger is released, `endFloatingCursor` | ||
| // will be called. In all cases, we send the relative point to the framework, so that framework |
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: relative to the initial position registered in beginFloatingCursorAtPoint or some such?
| // cursor. The process starts with `beginFloatingCursorAtPoint`. When the finger is moved, | ||
| // `updateFloatingCursorAtPoint` will be called. When the finger is released, `endFloatingCursor` | ||
| // will be called. In all cases, we send the relative point to the framework, so that framework | ||
| // can animate 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.
super nit: animate -> correctly position?
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's just visually animate without actually updating the position.
| // will be called. In all cases, we send the relative point to the framework, so that framework | ||
| // can animate the floating cursor. | ||
| // | ||
| // Notice that during the move gesture, the framework only animate the cursor visually. It's only |
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.
| // | ||
| // Notice that during the move gesture, the framework only animate the cursor visually. It's only | ||
| // after the gesture is complete, will the framework update the selection to the cursor's | ||
| // new position (with zero selection length). This means during the animation, the visual effect |
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.
after the gesture is complete, will the framework update the selection to the cursor's new position
I think this should probably be considered a bug? IIRC in a UIKit app the selection will actually be updated as you drag?
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'd say it's "by design" - we did it on purpose. not saying whether this design is good or bad.
| // Floating cursor's "selection" gesture also starts with 1 finger to force press the space bar, | ||
| // so exactly the same functions as the "move gesture" discussed above will be called. When the | ||
| // second finger is pressed, `setSelectedText` will be called. This mechanism requires | ||
| // `closestPositionFromPoint` to be implemented, so that UIKit can determine which text position |
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: ... to be implemented to allow UIKit to translate the finger touch location displacement to the text range to select.
| // of the cursor is temporarily out of sync with the selection state in both framework and engine. | ||
| // But it will be in sync again after the animation is complete. | ||
| // | ||
| // Floating cursor's "selection" gesture also starts with 1 finger to force press the space 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 vaguely remember the "selection" gesture doesn't call {start, update, end}FloatingCursor for the 2nd finger and that was the reason the whole selection thing had to be implemented in the iOS embedder (I think we usually prefer implementing selection handling logic in the framework to avoid synchronization problems), maybe mention that if it isn't documented already?
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 is only one start,update,...,end for the whole sequence whether it's one or two fingers. We do continue to get update calls during the second finger movement, but no specific event when the second finger is pressed.
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.
yeah this is something i should include. good that you remember it.
c3dc3e3 to
ce62668
Compare
|
auto label is removed for flutter/engine, pr: 42173, due to - The status or check suite Linux mac_unopt has failed. Please fix the issues identified (or deflake) before re-applying this label. |
…ating cursor feature (flutter/engine#42173)
…128726) flutter/engine@de68fba...12def73 2023-06-12 [email protected] [floating_cursor_selection] a somewhat "design doc" for floating cursor feature (flutter/engine#42173) 2023-06-12 [email protected] Roll ANGLE from 43ef50f389e9 to 21f16cb16333 (1 revision) (flutter/engine#42779) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR gives an overview of how floating cursor feature works (including the new floating cursor selection gesture, and the existing floating cursor move gesture). It can serve as the missing design doc.
I put it in the engine rather than the framework, since all logics are in one place, and it's closer to the UIKit behavior that I want to cover.
Thanks @moffatman for helping me understanding it.
List which issues are fixed by this PR. You must list at least one issue.
flutter/flutter#30476
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.