Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Temporary fix for bug #1639 SDL does not message back closing of scre…

…en keyboard

See FIXME notes on patch for details.
  • Loading branch information
gabomdq committed Aug 2, 2013
1 parent 90ed304 commit ab59089e3b5e518e022a50bc6c2c5727ba8fa9f6
Showing with 27 additions and 0 deletions.
  1. +18 −0 android-project/src/org/libsdl/app/SDLActivity.java
  2. +9 −0 src/core/android/SDL_android.c
@@ -236,6 +236,7 @@ boolean sendCommand(int command, Object data) {
public static native void onNativeResize(int x, int y, int format);
public static native void onNativeKeyDown(int keycode);
public static native void onNativeKeyUp(int keycode);
public static native void onNativeKeyboardFocusLost();
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
int action, float x,
float y, float p);
@@ -829,6 +830,23 @@ public boolean onKey(View v, int keyCode, KeyEvent event) {

return false;
}

//
@Override
public boolean onKeyPreIme (int keyCode, KeyEvent event) {
// As seen on StackOverflow: http://stackoverflow.com/questions/7634346/keyboard-hide-event
// FIXME: Discussion at http://bugzilla.libsdl.org/show_bug.cgi?id=1639
// FIXME: This is not a 100% effective solution to the problem of detecting if the keyboard is showing or not
// FIXME: A more effective solution would be to change our Layout from AbsoluteLayout to Relative or Linear
// FIXME: And determine the keyboard presence doing this: http://stackoverflow.com/questions/2150078/how-to-check-visibility-of-software-keyboard-in-android
// FIXME: An even more effective way would be if Android provided this out of the box, but where would the fun be in that :)
if (event.getAction()==KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
if (SDLActivity.mTextEdit != null && SDLActivity.mTextEdit.getVisibility() == View.VISIBLE) {
SDLActivity.onNativeKeyboardFocusLost();
}
}
return super.onKeyPreIme(keyCode, event);
}

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
@@ -162,6 +162,15 @@ void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
Android_OnKeyUp(keycode);
}

// Keyboard Focus Lost
void Java_org_libsdl_app_SDLActivity_onNativeKeyboardFocusLost(
JNIEnv* env, jclass jcls)
{
/* Calling SDL_StopTextInput will take care of hiding the keyboard and cleaning up the DummyText widget */
SDL_StopTextInput();
}


// Touch
void Java_org_libsdl_app_SDLActivity_onNativeTouch(
JNIEnv* env, jclass jcls,

0 comments on commit ab59089

Please sign in to comment.