Skip to content

Commit

Permalink
[Android] Fixes Bug 2031 - Backspace Not Sending Events From On-Scree…
Browse files Browse the repository at this point in the history
…n Keyboard

Thanks Joe LeVeque!
  • Loading branch information
gabomdq committed Nov 11, 2013
1 parent d37bad5 commit 6dbed82
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -825,6 +825,17 @@ public boolean setComposingText(CharSequence text, int newCursorPosition) {

public native void nativeSetComposingText(String text, int newCursorPosition);

@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
if (beforeLength == 1 && afterLength == 0) {
// backspace
return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
&& super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
}

return super.deleteSurroundingText(beforeLength, afterLength);
}
}

/* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */
Expand Down

0 comments on commit 6dbed82

Please sign in to comment.