[Android] Fixes Bug 2031 - Backspace Not Sending Events From On-Screen Keyboard
authorGabriel Jacobo <gabomdq@gmail.com>
Mon, 11 Nov 2013 10:59:15 -0300
changeset 7958b8f431cd7819
parent 7957 5d9563c4f4b6
child 7959 fb3307cd5609
[Android] Fixes Bug 2031 - Backspace Not Sending Events From On-Screen Keyboard

Thanks Joe LeVeque!
android-project/src/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/src/org/libsdl/app/SDLActivity.java	Mon Nov 11 10:49:48 2013 -0300
     1.2 +++ b/android-project/src/org/libsdl/app/SDLActivity.java	Mon Nov 11 10:59:15 2013 -0300
     1.3 @@ -825,6 +825,17 @@
     1.4  
     1.5      public native void nativeSetComposingText(String text, int newCursorPosition);
     1.6  
     1.7 +    @Override
     1.8 +    public boolean deleteSurroundingText(int beforeLength, int afterLength) {       
     1.9 +        // Workaround to capture backspace key. Ref: http://stackoverflow.com/questions/14560344/android-backspace-in-webview-baseinputconnection
    1.10 +        if (beforeLength == 1 && afterLength == 0) {
    1.11 +            // backspace
    1.12 +            return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
    1.13 +                && super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
    1.14 +        }
    1.15 +
    1.16 +        return super.deleteSurroundingText(beforeLength, afterLength);
    1.17 +    }
    1.18  }
    1.19  
    1.20  /* A null joystick handler for API level < 12 devices (the accelerometer is handled separately) */