Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@edman
Copy link
Contributor

@edman edman commented Jan 13, 2020

Includes selection, copy, cut, paste, as well as partial support for up
and down movement.

Text editing controls can be accessed in GBoard by:
top-left arrow > three dots menu > text editing

Partial fix for flutter/flutter#9419 and flutter/flutter#37371.

Before

After

@auto-assign auto-assign bot requested a review from GaryQian January 13, 2020 21:29
@edman edman requested a review from justinmc January 13, 2020 21:30
@edman
Copy link
Contributor Author

edman commented Jan 13, 2020

Some comments about the limitations of this PR:

  • Home/End are not supported. I'm not sure where events for those keys are sent in the engine.

  • Up/Down work except when moving around long lines that wrap around the view (see the video above). Basically the InputConnectionAdaptor does not know the width of the text view and thinks text always fits.

    // We create a dummy Layout with max width so that the selection
    // shifting acts as if all text were in one line.
    mLayout = new DynamicLayout(mEditable, new TextPaint(), Integer.MAX_VALUE, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);

@edman edman force-pushed the textediting branch 3 times, most recently from 93d68c7 to 04685c5 Compare January 13, 2020 22:00
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

A few nitpicks but otherwise LGTM 👍

Right now this will not support the home/end buttons, so we should add a note to flutter/flutter#9419 about that when this is merged.

@GaryQian Any last minute ideas for getting the width here? Otherwise I think the current up/down arrow behavior is ok for now. Also, what do you think about tests for this?

@GaryQian
Copy link
Contributor

Obtaining the width at the embedder level is non-trivial. Unless it is urgently needed, I would hold off on developing a system to pass width down to there.

The sendKeyEvent method should be unit-testable?

@justinmc
Copy link
Contributor

Alright let's leave the up/down behavior as-is for now and revisit if needed.

Unit testing sounds like a good idea. @edman You'll have to add a new unit test file for this since one doesn't already exist for InputConnectionAdaptor unfortunately. It should be somewhat similar to the unit test file added in this PR: https://github.com/flutter/engine/pull/12432/files#diff-af19d10c7a69b9cab3ee96c4f64a9a9cR1

Comment on lines 209 to 213
// WIP
// The asserts below don't work. KEYCODE_DPAD_UP moves the caret to
// index 0, as if the text were in one single line.
// assertEquals(expectedSelection, Selection.getSelectionStart(editable));
// assertEquals(expectedSelection, Selection.getSelectionEnd(editable));
Copy link
Contributor Author

@edman edman Jan 16, 2020

Choose a reason for hiding this comment

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

Couldn't get the up/down tests to work as expected yet.

Up moves selection to beginning of the text and down moves to end. There's a line break in the text so it should move to the next/previous line instead.

Not sure why it behaves differently in tests.. Will look more tomorrow.

Copy link
Contributor

@GaryQian GaryQian Jan 31, 2020

Choose a reason for hiding this comment

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

So I have noticed through working on other bugs that depending on the input method, some keystrokes/events do not pass through this method at all. I am not yet clear on where those events go but that behavior may have something to do with this.

@justinmc
Copy link
Contributor

justinmc commented Feb 18, 2020

We should check whether this fixes flutter/flutter#50875. Nevermind, that issue is iOS specific.

@gschier
Copy link

gschier commented Feb 19, 2020

RenderEditable contains its own logic for arrow navigation of hardware keyboards, including up/down. Could leave it up to the UI layer for this too maybe.

https://github.com/flutter/flutter/blob/11549e45a386220cbacd683b8a94cbac85d62a41/packages/flutter/lib/src/rendering/editable.dart#L480

@edman
Copy link
Contributor Author

edman commented Feb 26, 2020

@justinmc I changed the test logic and added a note.

Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

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

LGTM

I think this way of doing the tests is fine with the note. There is one failure, I'll try to see if it's an infrastructure thing.

@justinmc justinmc added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Feb 28, 2020
@justinmc
Copy link
Contributor

@gschier Thanks for pointing that out, I hadn't realized it was being handled in both places. I talked to @gspencergoog and it sounds like it's due for a refactor to consolidate. This should be fine for now.

@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Mac Web Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Feb 28, 2020
@justinmc
Copy link
Contributor

Hmm I reran that failure and it succeeded, but it's still red. @edman Can you try merging with master and pushing?

Includes selection, copy, cut, paste, as well as partial support for up
and down movement.

Text editing controls can be accessed in GBoard by:
  top-left arrow > three dots menu > text editing

Partial fix for flutter/flutter#9419 and flutter/flutter#37371.
Run with:
  testing/run_tests.py --type=java --java-filter=io.flutter.plugin.editing.InputConnectionAdaptorTest
@edman
Copy link
Contributor Author

edman commented Feb 28, 2020

@GaryQian FYI we'll be landing this once the tree is green.

@edman edman merged commit 9beac71 into flutter:master Feb 28, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Feb 29, 2020
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 2, 2020
cbracken pushed a commit to flutter/flutter that referenced this pull request Mar 2, 2020
* 9beac71 Add support for software text editing controls (flutter/engine#15560)

* ab9f83f Roll fuchsia/sdk/core/linux-amd64 from RYDur... to bgFop... (flutter/engine#16855)

* 62d0c08 Roll src/third_party/dart dda5bcee00d3..4dad6d77ba50 (6 commits) (flutter/engine#16856)

* 76d12d2 Roll src/third_party/skia 03d9e8af0d25..262796edeba6 (11 commits) (flutter/engine#16857)

* 01a52b9 Try rasterizing images and layers only once, even when their rasterization fails. Further enforce the same access threshold on layers as on Pictures. Previously layers would always be cached. The latter is a semantic change. (flutter/engine#16545)

* 3b0d1a8 script for fetching correct flutter version (flutter/engine#16818)

* 9746ddb Roll src/third_party/dart 4dad6d77ba50..6708f6d4c7df (15 commits) (flutter/engine#16860)

* 90736bb Roll src/third_party/skia 262796edeba6..54cb21430ccb (23 commits) (flutter/engine#16861)

* 142882e Roll src/third_party/skia 54cb21430ccb..e1ae9c4bcf2e (4 commits) (flutter/engine#16863)

* 7192356 Manual roll of Dart 09bbd3cca5...6708f6d4c7 (flutter/engine#16864)

* fae5ff6 Roll src/third_party/skia e1ae9c4bcf2e..5d1c3e2ead61 (2 commits) (flutter/engine#16865)

* c6525a4 Roll src/third_party/skia 5d1c3e2ead61..59b160f99106 (2 commits) (flutter/engine#16866)

* 755e2b5 Roll src/third_party/skia 59b160f99106..71a20b2685c6 (1 commits) (flutter/engine#16867)

* 93d0eff Roll src/third_party/skia 71a20b2685c6..ecbb0fb2d5bc (1 commits) (flutter/engine#16869)

* bfee5ae Roll fuchsia/sdk/core/linux-amd64 from bgFop... to F_Ihm... (flutter/engine#16871)

* ca29b47 Roll fuchsia/sdk/core/mac-amd64 from K26F5... to 79I0C... (flutter/engine#16872)

* 708ca2c Roll src/third_party/skia ecbb0fb2d5bc..666707336e07 (1 commits) (flutter/engine#16873)

* 78ea291 Roll fuchsia/sdk/core/mac-amd64 from 79I0C... to NoQzJ... (flutter/engine#16874)

* 7b43bb8 Roll fuchsia/sdk/core/linux-amd64 from F_Ihm... to 22R78... (flutter/engine#16875)

* 75c9c62 Roll src/third_party/skia 666707336e07..231f1bf56556 (1 commits) (flutter/engine#16876)

* 7a86b83 Roll src/third_party/dart 09bbd3cca5d4..860dca93ea42 (1 commits) (flutter/engine#16877)

* d0c87e2 Roll src/third_party/skia 231f1bf56556..d6205322cdc5 (1 commits) (flutter/engine#16878)

* b4c5854 Roll src/third_party/skia d6205322cdc5..6729496a037f (1 commits) (flutter/engine#16879)

* 03f0ee5 Roll src/third_party/skia 6729496a037f..367dbff98555 (1 commits) (flutter/engine#16880)

* d84b968 Roll fuchsia/sdk/core/mac-amd64 from NoQzJ... to q2DAy... (flutter/engine#16881)

* 4490e7c Roll fuchsia/sdk/core/linux-amd64 from 22R78... to 9NHsJ... (flutter/engine#16882)

* a39e7ac Roll src/third_party/skia 367dbff98555..986680240f81 (1 commits) (flutter/engine#16884)

* 62b1e50 Roll src/third_party/dart 860dca93ea42..fbe9f6115d2f (9 commits) (flutter/engine#16885)

* 5e474ee Roll src/third_party/skia 986680240f81..9dd0bd78b2d7 (2 commits) (flutter/engine#16886)
auto-submit bot pushed a commit that referenced this pull request May 17, 2023
Fixes flutter/flutter#101569

This block of code was originally introduced in #15560 , but removing it does not have any affect on the software text editing controls in GBoard.

Before this change
* shift + arrow right/left selection would collapse after releasing the shift key. 
* shift + mouse click to expand selection would collapse after releasing the shift key.

After this change
* shift key up no longer collapses the selection.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants