Support sendKeyEvent for arrow keys (flutter/engine#3940)

Fixes https://github.com/flutter/flutter/issues/11352
This commit is contained in:
Jason Simmons
2017-07-31 16:52:34 -07:00
committed by GitHub
parent 94f1311b9e
commit 521031a50c

View File

@@ -141,6 +141,14 @@ class InputConnectionAdaptor extends BaseInputConnection {
Selection.setSelection(mEditable, selStart - 1);
deleteSurroundingText(0, 1);
}
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
int selStart = Selection.getSelectionStart(mEditable);
int newSel = Math.max(selStart - 1, 0);
setSelection(newSel, newSel);
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_RIGHT) {
int selStart = Selection.getSelectionStart(mEditable);
int newSel = Math.min(selStart + 1, mEditable.length());
setSelection(newSel, newSel);
} else {
// Enter a character.
int character = event.getUnicodeChar();