From f91b87859c4fd2097cb9c7290bd0fcf58c9dd56c Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Thu, 23 May 2019 09:08:40 +0200 Subject: [PATCH] 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. --- .../app/src/main/java/org/libsdl/app/SDLActivity.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java index 891721295c734..17697daac61b6 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLActivity.java @@ -1029,6 +1029,14 @@ public ShowTextInputTask(int x, int y, int w, int h) { this.y = y; this.w = w; this.h = h; + + /* Minimum size of 1 pixel, so it takes focus. */ + if (this.w <= 0) { + this.w = 1; + } + if (this.h + HEIGHT_PADDING <= 0) { + this.h = 1 - HEIGHT_PADDING; + } } @Override