[Commits] SDL: Fixed bug 4004 - iOS: don't hide keyboard on RETURN

libsdl.org revision control commits-owner at libsdl.org
Tue Dec 19 10:57:23 PST 2017


details:   https://hg.libsdl.org/SDL/rev/98ea6e4c0d68
changeset: 11782:98ea6e4c0d68
user:      Sam Lantinga <slouken at libsdl.org>
date:      Tue Dec 19 10:57:21 2017 -0800
description:
Fixed bug 4004 - iOS: don't hide keyboard on RETURN

Dominik Reichardt

As discussed in 2012 the iOS onscreen keyboard hides when you hit RETURN (see https://discourse.libsdl.org/t/on-screen-keyboard-change/19216).
IMO this is a bad idea to not be able to influence this behavior and just recently this was fixed for Android by adding the hint SDL_HINT_ANDROID_RETURN_HIDES_IME in changeset 11768	0f2fb9ec6ad6.

diffstat:

 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java |  2 +-
 include/SDL_hints.h                                               |  9 ++++-----
 src/video/uikit/SDL_uikitviewcontroller.m                         |  4 +++-
 3 files changed, 8 insertions(+), 7 deletions(-)

diffs (51 lines):

diff -r c2f3e4187c9d -r 98ea6e4c0d68 android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
--- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Dec 19 10:48:29 2017 -0800
+++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Tue Dec 19 10:57:21 2017 -0800
@@ -1508,7 +1508,7 @@
          */
 
         if (event.getKeyCode() == 66) {
-            String imeHide = SDLActivity.nativeGetHint("SDL_ANDROID_RETURN_HIDES_IME");
+            String imeHide = SDLActivity.nativeGetHint("SDL_RETURN_KEY_HIDES_IME");
             if ((imeHide != null) && imeHide.equals("1")) {
                 Context c = SDL.getContext();
                 if (c instanceof SDLActivity) {
diff -r c2f3e4187c9d -r 98ea6e4c0d68 include/SDL_hints.h
--- a/include/SDL_hints.h	Tue Dec 19 10:48:29 2017 -0800
+++ b/include/SDL_hints.h	Tue Dec 19 10:57:21 2017 -0800
@@ -721,17 +721,16 @@
 #define SDL_HINT_ANDROID_SEPARATE_MOUSE_AND_TOUCH "SDL_ANDROID_SEPARATE_MOUSE_AND_TOUCH"
 
  /**
- * \brief A variable to control whether the return key on the soft keyboard should hide the 
- * soft keyboard on Android.
+ * \brief A variable to control whether the return key on the soft keyboard
+ *        should hide the soft keyboard on Android and iOS.
  *
  * The variable can be set to the following values:
- *   "0"       - The return key will be handled as a key event. This is the behaviour of 
- *               SDL <= 2.0.3. (default)
+ *   "0"       - The return key will be handled as a key event. This is the behaviour of SDL <= 2.0.3. (default)
  *   "1"       - The return key will hide the keyboard.
  *
  * The value of this hint is used at runtime, so it can be changed at any time.
  */
-#define SDL_HINT_ANDROID_RETURN_HIDES_IME "SDL_ANDROID_RETURN_HIDES_IME"
+#define SDL_HINT_RETURN_KEY_HIDES_IME "SDL_RETURN_KEY_HIDES_IME"
 
 /**
  *  \brief override the binding element for keyboard inputs for Emscripten builds
diff -r c2f3e4187c9d -r 98ea6e4c0d68 src/video/uikit/SDL_uikitviewcontroller.m
--- a/src/video/uikit/SDL_uikitviewcontroller.m	Tue Dec 19 10:48:29 2017 -0800
+++ b/src/video/uikit/SDL_uikitviewcontroller.m	Tue Dec 19 10:57:21 2017 -0800
@@ -387,7 +387,9 @@
 {
     SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN);
     SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN);
-    SDL_StopTextInput();
+    if (SDL_GetHintBoolean(SDL_HINT_RETURN_KEY_HIDES_IME, SDL_FALSE)) {
+         SDL_StopTextInput();
+    }
     return YES;
 }
 


More information about the commits mailing list