From 521031a50c395cec7ce66353ea100f0aa6c4389b Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Mon, 31 Jul 2017 16:52:34 -0700 Subject: [PATCH] Support sendKeyEvent for arrow keys (flutter/engine#3940) Fixes https://github.com/flutter/flutter/issues/11352 --- .../io/flutter/plugin/editing/InputConnectionAdaptor.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java index 4f2088fdf7..2e099e9772 100644 --- a/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java +++ b/engine/src/flutter/shell/platform/android/io/flutter/plugin/editing/InputConnectionAdaptor.java @@ -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();