Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove engine-side delete key handling.
  • Loading branch information
gspencergoog committed Nov 20, 2020
commit 15217bbcaa19b2a42cb8c5427ad4efee25d94ee4
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ private static int clampIndexToEditable(int index, Editable editable) {

@Override
public boolean sendKeyEvent(KeyEvent event) {
Log.w(TAG, "Received " + (event.getAction() == KeyEvent.ACTION_DOWN ? "down" : "up") + " event for " + Character.getName(event.getUnicodeChar()));
// Give the key processor a chance to process this event. It will send it
// to the framework to be handled and return true. If the framework ends up
// not handling it, the processor will re-send the event, this time
Expand All @@ -296,21 +297,22 @@ public boolean sendKeyEvent(KeyEvent event) {
}

if (event.getAction() == KeyEvent.ACTION_DOWN) {
if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
int selStart = clampIndexToEditable(Selection.getSelectionStart(mEditable), mEditable);
int selEnd = clampIndexToEditable(Selection.getSelectionEnd(mEditable), mEditable);
if (selStart == selEnd && selStart > 0) {
// Extend selection to left of the last character
selStart = flutterTextUtils.getOffsetBefore(mEditable, selStart);
}
if (selEnd > selStart) {
// Delete the selection.
Selection.setSelection(mEditable, selStart);
mEditable.delete(selStart, selEnd);
return true;
}
return false;
} else if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
// if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
// int selStart = clampIndexToEditable(Selection.getSelectionStart(mEditable), mEditable);
// int selEnd = clampIndexToEditable(Selection.getSelectionEnd(mEditable), mEditable);
// if (selStart == selEnd && selStart > 0) {
// // Extend selection to left of the last character
// selStart = flutterTextUtils.getOffsetBefore(mEditable, selStart);
// }
// if (selEnd > selStart) {
// // Delete the selection.
// Selection.setSelection(mEditable, selStart);
// mEditable.delete(selStart, selEnd);
// return true;
// }
// return false;
// } else
if (event.getKeyCode() == KeyEvent.KEYCODE_DPAD_LEFT) {
int selStart = Selection.getSelectionStart(mEditable);
int selEnd = Selection.getSelectionEnd(mEditable);
if (selStart == selEnd && !event.isShiftPressed()) {
Expand Down