Android: minimum size for IME, so that it takes focus
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 23 May 2019 09:08:40 +0200
changeset 1275106fa9a25d2a0
parent 12750 455b89ce7384
child 12752 53a3b17a1c08
Android: minimum size for IME, so that it takes focus

In API 28, 0 width views can't take focus, so if someone tries to position the IME without setting a width, they'll stop getting text events.

Tested on Android 9: with a 0 size, it would send correctly letters a, b, c, etc. but not numbers.
android-project/app/src/main/java/org/libsdl/app/SDLActivity.java
     1.1 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Wed May 22 17:39:51 2019 -0700
     1.2 +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java	Thu May 23 09:08:40 2019 +0200
     1.3 @@ -1029,6 +1029,14 @@
     1.4              this.y = y;
     1.5              this.w = w;
     1.6              this.h = h;
     1.7 +
     1.8 +            /* Minimum size of 1 pixel, so it takes focus. */
     1.9 +            if (this.w <= 0) {
    1.10 +                this.w = 1;
    1.11 +            }
    1.12 +            if (this.h + HEIGHT_PADDING <= 0) {
    1.13 +                this.h = 1 - HEIGHT_PADDING;
    1.14 +            }
    1.15          }
    1.16  
    1.17          @Override