engine
engine copied to clipboard
Android Input Failed When TextInputType Is Phone, Number
Fix Issue: 98352
In current case is not cursor selector
but current logic number input is will check the Selection
range
When the TextInputType
is Number
, and you input text, the keyboard will sendKeyEvent
, and next entry the handleKeyEvent
method
public boolean handleKeyEvent(KeyEvent event) {
...
// Enter a character.
final int selStart = Selection.getSelectionStart(mEditable);
final int selEnd = Selection.getSelectionEnd(mEditable);
final int character = event.getUnicodeChar();
if (selStart < 0 || selEnd < 0 || character == 0) {
return false;
}
...
}
When first number entry this method the selStart
and selEnd
will be -1
, because there is no cursor and thus the Selection.start is not attach. The getSelectionStart
will return -1
We need to support logic that without a cursor, and need support delete action.
Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities.
- [x] I read and followed the [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
- [x] I listed at least one issue that this PR fixes in the description above.
- [x] I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
- [x] I updated/added relevant documentation (doc comments with
///
). - [x] I signed the [CLA].
- [x] All existing and new tests are passing.
I think there is an open question for @LongCatIsLooong
From PR review triage: There are open questions for @JsouLiang and @gspencergoog
@JsouLiang Hi there again from PR triage. Are you interested in continuing with this PR? If so, it looks like there are some open questions for you. Thanks!
@zanderso hey, yes i am interested in continuing with this PR, but i have some problems need to ask @LongCatIsLooong. Thanks.
cc @LongCatIsLooong Are you able to reply to @JsouLiang query?
Sorry for the delayed reply. @JsouLiang looks like the handleDelete
implementation in the pull request doesn't handle surrogate pairs or combining characters. The logic that handles that currently lives in the framework since that's much easier to maintain than implementing/maintaining the same thing for each platform. There's ongoing work to expose more things to help developers build their own TextInputClient
s from scratch but for now should they choose to implement TextInputClient
themselves, they'll have to handle delete
themselves.
Is this any update? I still met this issue on android with Flutter v3.7.12