Files
godot/platform/android/java/lib
Voyend c0bb5a2d1f Fix backspace not deleting original text in soft keyboard on Android
When a soft keyboard's backspace sends KEYCODE_DEL via sendKeyEvent(),
GodotEditText.onKeyDown() delegates to super.onKeyDown() which modifies
the EditText's Editable, triggering beforeTextChanged() in
GodotTextInputWrapper, which then forwards KEYCODE_DEL to the engine.

However, the EditText is only seeded with text up to the cursor position
(mOriginText) when the keyboard opens. Once the user backspaces through
all of that content, the EditText becomes empty. At that point,
super.onKeyDown(KEYCODE_DEL) on an empty EditText makes no change to the
Editable, so beforeTextChanged() never fires and the engine receives no
DEL event — even though the engine's own buffer still has text before
the cursor.

This causes a visible bug: the user can delete characters they typed in
the current session, but backspacing further into pre-existing text does
nothing. Re-tapping the field fixes it temporarily because showKeyboard()
is called again, reseeding the EditText with the current text and cursor
position.

Fixed this by forwarding KEYCODE_DEL directly to the engine when the
EditText is empty, bypassing the TextWatcher path that can't fire in
that state. This produces no double events since beforeTextChanged()
is physically unable to fire on an empty field.

Move DEL release event from onKeyDown to onKeyUp
2026-06-12 17:21:41 +03:00
..