Merge "Exit active mode on Escape key" into udc-dev

This commit is contained in:
Josep del Río
2023-03-14 11:46:57 +00:00
committed by Android (Google) Code Review

View File

@@ -360,6 +360,15 @@ public class QwertyKeyListener extends BaseKeyListener {
return super.onKeyDown(view, content, keyCode, event);
}
return true;
}
} else if (keyCode == KeyEvent.KEYCODE_ESCAPE && event.hasNoModifiers()) {
// If user is in the process of composing with a dead key, and
// presses Escape, cancel it. We need special handling because
// the Escape key will not produce a Unicode character
if (activeStart == selStart && activeEnd == selEnd) {
Selection.setSelection(content, selEnd);
content.removeSpan(TextKeyListener.ACTIVE);
return true;
}
}