1

In a nutchell my question is:

How can I show a soft-keyboard when accessing a LibGDX HTML (GWT) app via a mobile phone?

Details

In LibGDX, to bring up the soft-keyboard we can call this method:

Gdx.input.setOnscreenKeyboardVisible(true);

However, according to the documentation (https://github.com/libgdx/libgdx/wiki/On-screen-keyboard):

"On-screen keyboard functionality is only available the Android and iOS platforms"

i.e.: not for HTML (GWT)

Problem: If you access your HTML (GWT) application through a mobile or tablet, you have no way to show the soft-keyboard and therefore no way of typing anything in your texfield.

Given that most people are now accessing web sites using mobiles and/or tablets I assume many would haved face the same issue.

Julien
  • 1,028
  • 9
  • 18

2 Answers2

0

I'm pretty sure that it is not about LibGDX but about mobile browser itself - think about it like about handling input from some device (like keyboard) which actually should work both on PC and mobile devices - the keyboard is just not visible.

Then you should rather look for a solution of showing keyboard in mobile browser no matter if it is LibGDX application or not.

Here are some examples:

The general thing (and what also my small tests showed) is that you generally not allowed to open keyboard from script context. Maybe there is a hack for this but I'm pretty sure that at least it won't be working on every browser.

Since that I would rather recommend to use some input or to just implement your own "input layer" - user interface by using some kind of buttons.

Community
  • 1
  • 1
m.antkowicz
  • 13,268
  • 18
  • 37
  • Thanks it bugs me that when, using the LibGDX API, I call 'setOnscreenKeyboardVisible', on Android and on iOS it shows the soft-keyboard. If I do the same thing, on the same device. using the same method, using the same code but compiling for the HTML target it does not. I would have thought the point of having the unified backends was to offer the same behaviour regardless of the target, right? – Julien Jun 01 '16 at 11:52
  • Your platform now is GWT/HTML not Android or IOS - it does not matter that you are running the website on Android device - the project is being treated as it is GWT's one. If you want the application to behave like Android you need to compile it to .apk – m.antkowicz Jun 01 '16 at 12:43
  • Sorry, just to understand: your advice would be to call platform specific code in which I would make javascript calls to trigger the soft-keyboard or to recreate a keyboard using buttons. right? I cannot imagine that I am the first LibGDX user to ask users to key something in a TextField or TextArea in a GWT based app. As it stands you cannot do it if you access the page with a tablet or a phone. – Julien Jun 01 '16 at 16:47
  • By the way: it looks like someone else raised this question as an issue on the LibGDX trunk. https://github.com/libgdx/libgdx/issues/4117 – Julien Jun 02 '16 at 12:32
0

For the GWT application I ended up creating a softkeyboard with:

  • A Keyboard image
  • An actor per letter with an action listener

Then an Action resolver for showKeyboard. If GWT show the soft keyboard.

Julien
  • 1,028
  • 9
  • 18