mirror of https://github.com/encounter/SDL.git
Fixed hiding the Android virtual keyboard when the return key is pressed
This commit is contained in:
parent
f91b87859c
commit
8b57331e71
|
@ -762,6 +762,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
||||||
public static native void onNativeResize();
|
public static native void onNativeResize();
|
||||||
public static native void onNativeKeyDown(int keycode);
|
public static native void onNativeKeyDown(int keycode);
|
||||||
public static native void onNativeKeyUp(int keycode);
|
public static native void onNativeKeyUp(int keycode);
|
||||||
|
public static native boolean onNativeSoftReturnKey();
|
||||||
public static native void onNativeKeyboardFocusLost();
|
public static native void onNativeKeyboardFocusLost();
|
||||||
public static native void onNativeMouse(int button, int action, float x, float y, boolean relative);
|
public static native void onNativeMouse(int button, int action, float x, float y, boolean relative);
|
||||||
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
|
public static native void onNativeTouch(int touchDevId, int pointerFingerId,
|
||||||
|
@ -2087,14 +2088,8 @@ class SDLInputConnection extends BaseInputConnection {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
|
||||||
String imeHide = SDLActivity.nativeGetHint("SDL_RETURN_KEY_HIDES_IME");
|
if (SDLActivity.onNativeSoftReturnKey()) {
|
||||||
if ((imeHide != null) && imeHide.equals("1")) {
|
return true;
|
||||||
Context c = SDL.getContext();
|
|
||||||
if (c instanceof SDLActivity) {
|
|
||||||
SDLActivity activity = (SDLActivity)c;
|
|
||||||
activity.sendCommand(SDLActivity.COMMAND_TEXTEDIT_HIDE, null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2107,6 +2102,11 @@ class SDLInputConnection extends BaseInputConnection {
|
||||||
|
|
||||||
for (int i = 0; i < text.length(); i++) {
|
for (int i = 0; i < text.length(); i++) {
|
||||||
char c = text.charAt(i);
|
char c = text.charAt(i);
|
||||||
|
if (c == '\n') {
|
||||||
|
if (SDLActivity.onNativeSoftReturnKey()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
nativeGenerateScancodeForUnichar(c);
|
nativeGenerateScancodeForUnichar(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,9 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
|
||||||
JNIEnv *env, jclass jcls,
|
JNIEnv *env, jclass jcls,
|
||||||
jint keycode);
|
jint keycode);
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
||||||
|
JNIEnv *env, jclass jcls);
|
||||||
|
|
||||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
|
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
|
||||||
JNIEnv *env, jclass jcls);
|
JNIEnv *env, jclass jcls);
|
||||||
|
|
||||||
|
@ -920,6 +923,17 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyUp)(
|
||||||
Android_OnKeyUp(keycode);
|
Android_OnKeyUp(keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Virtual keyboard return key might stop text input */
|
||||||
|
JNIEXPORT jboolean JNICALL SDL_JAVA_INTERFACE(onNativeSoftReturnKey)(
|
||||||
|
JNIEnv *env, jclass jcls)
|
||||||
|
{
|
||||||
|
if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
|
||||||
|
SDL_StopTextInput();
|
||||||
|
return JNI_TRUE;
|
||||||
|
}
|
||||||
|
return JNI_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Keyboard Focus Lost */
|
/* Keyboard Focus Lost */
|
||||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
|
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(onNativeKeyboardFocusLost)(
|
||||||
JNIEnv *env, jclass jcls)
|
JNIEnv *env, jclass jcls)
|
||||||
|
@ -1127,7 +1141,6 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeGenerateScancod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
|
JNIEXPORT void JNICALL SDL_JAVA_INTERFACE_INPUT_CONNECTION(nativeSetComposingText)(
|
||||||
JNIEnv *env, jclass cls,
|
JNIEnv *env, jclass cls,
|
||||||
jstring text, jint newCursorPosition)
|
jstring text, jint newCursorPosition)
|
||||||
|
|
Loading…
Reference in New Issue