Support sendKeyEvent for arrow keys (#3940)
Fixes https://github.com/flutter/flutter/issues/11352
diff --git a/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java b/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
index 4f2088f..2e099e9 100644
--- a/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
+++ b/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java
@@ -141,6 +141,14 @@
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();