2

When you tap on a TextField in LibGDX, sometimes it can stay behind the onscreen-keyboard. You can't see what you are typing. I'm using TextInputListener to avoid this problem:

textPassword.setOnscreenKeyboard(new TextField.OnscreenKeyboard() {
    @Override
    public void show(boolean visible) {
        Gdx.input.getTextInput(new Input.TextInputListener() {
            @Override
            public void input(String text) {
                textPassword.setText(text);
            }

            @Override
            public void canceled() {
            }

        }, "" , "", "");
    }
});

But in this way, data entry is possible in two steps:

Step-1: https://i.ibb.co/vYHGrJj/1.png

Step-2: https://i.ibb.co/m5D3FMq/2.png

This is not a user-friendly approach.

Is it possible to skip the first step and start the second step directly?

Happy Man
  • 57
  • 5

2 Answers2

1

In my games, I work with opening a TextInput dialog (Gdx.input.getTextInput) when the user taps on a text field if there's no hardware keyboard connectect (isPeriphalAvailable) . I would recommend you to also do so to avoid typical problems.

MrStahlfelge
  • 1,721
  • 2
  • 13
  • 23
0

In Android, there are some keywords to use for this purpose. For example,

<activity
        android:name=".example"
        android:theme="@style/AppTheme.NoActionBar"
        android:windowSoftInputMode="adjustResize" />

adjustResize, adjustResize|stateHidden, adjustPan, adjustPan|adjustResize

You should try these in Android Manifest.Xml which is your application runs on. But I am not sure if this still works on LibgdxFrame which is basically created with OpenGL backend. I suggest that you should put your Dialog closer to the top of screen if its possible.

Notice that this problem can be occur in iOS devices if you want to deploy to iOS

Abdullah Tellioglu
  • 1,434
  • 1
  • 10
  • 26
  • This actually doesn't work on libgdx. In any case, a resize is rarely what is needed and `adjustPan` sometimes pushes the input out of the screen. So a dialog is the way to go. – Nicolas Nov 08 '19 at 15:32