src/core/android/SDL_android.cpp
changeset 6555 f2c03c06d987
parent 6464 ab55284b389f
child 6630 55910871076b
     1.1 --- a/src/core/android/SDL_android.cpp	Wed Oct 03 20:22:14 2012 -0700
     1.2 +++ b/src/core/android/SDL_android.cpp	Wed Oct 03 20:49:16 2012 -0700
     1.3 @@ -218,6 +218,30 @@
     1.4      Android_RunAudioThread();
     1.5  }
     1.6  
     1.7 +extern "C" void Java_org_libsdl_app_SDLInputConnection_nativeCommitText(
     1.8 +                                    JNIEnv* env, jclass cls,
     1.9 +                                    jstring text, jint newCursorPosition)
    1.10 +{
    1.11 +    const char *utftext = env->GetStringUTFChars(text, NULL);
    1.12 +
    1.13 +    SDL_SendKeyboardText(utftext);
    1.14 +
    1.15 +    env->ReleaseStringUTFChars(text, utftext);
    1.16 +}
    1.17 +
    1.18 +extern "C" void Java_org_libsdl_app_SDLInputConnection_nativeSetComposingText(
    1.19 +                                    JNIEnv* env, jclass cls,
    1.20 +                                    jstring text, jint newCursorPosition)
    1.21 +{
    1.22 +    const char *utftext = env->GetStringUTFChars(text, NULL);
    1.23 +
    1.24 +    SDL_SendEditingText(utftext, 0, 0);
    1.25 +
    1.26 +    env->ReleaseStringUTFChars(text, utftext);
    1.27 +}
    1.28 +
    1.29 +
    1.30 +
    1.31  
    1.32  /*******************************************************************************
    1.33               Functions called by SDL into Java
    1.34 @@ -918,6 +942,42 @@
    1.35      return 0;
    1.36  }
    1.37  
    1.38 +extern "C" int Android_JNI_ShowTextInput(SDL_Rect *inputRect)
    1.39 +{
    1.40 +    JNIEnv *env = Android_JNI_GetEnv();
    1.41 +    if (!env) {
    1.42 +        return -1;
    1.43 +    }
    1.44 +
    1.45 +    jmethodID mid = env->GetStaticMethodID(mActivityClass, "showTextInput", "(IIII)V");
    1.46 +    if (!mid) {
    1.47 +        return -1;
    1.48 +    }
    1.49 +    env->CallStaticVoidMethod( mActivityClass, mid,
    1.50 +                               inputRect->x,
    1.51 +                               inputRect->y,
    1.52 +                               inputRect->w,
    1.53 +                               inputRect->h );
    1.54 +    return 0;
    1.55 +}
    1.56 +
    1.57 +/*extern "C" int Android_JNI_HideTextInput()
    1.58 +{
    1.59 +
    1.60 +
    1.61 +    JNIEnv *env = Android_JNI_GetEnv();
    1.62 +    if (!env) {
    1.63 +        return -1;
    1.64 +    }
    1.65 +
    1.66 +    jmethodID mid = env->GetStaticMethodID(mActivityClass, "hideTextInput", "()V");
    1.67 +    if (!mid) {
    1.68 +        return -1;
    1.69 +    }
    1.70 +    env->CallStaticVoidMethod(mActivityClass, mid);
    1.71 +    return 0;
    1.72 +}*/
    1.73 +
    1.74  #endif /* __ANDROID__ */
    1.75  
    1.76  /* vi: set ts=4 sw=4 expandtab: */