Libgdx: iOS on-screen keyboard does not fire events sequentially

I am having problems with InputProcessor only on my IOS build. This code works for desktop computers and Android, but not for iOS.

Basically, I need to catch an event at any time when the user types on the on-screen keyboard. But on iOS, I only see my println for keyTyped intermittently and only when I quickly type on the on-screen keyboard. All other touches just show a new line in the console, I don’t know where this new line output comes from.

The problem seems to be related to the fact that iOS sends events back to my application and how LibGDX InputProcessor receives them. I tried to create my own object that extends TextField and implements InputProcessor, and then sets an instance of this object as input processor, but I get the same result. If I touch anywhere on the screen that is not an iOS on-screen keyboard, I get events firing sequentially.

This is what the output of the iOS console looks like when I type very fast, if I type slowly, println never appears:

game name field key typed!


game name field key typed!






game name field key typed!

Doing the same on an Android device (nexus 7) gives the following (what I expect):

I/System.out: game name field key down!
I/System.out: game name field key up!
I/System.out: game name field key typed!
I/System.out: game name field key down!
I/System.out: game name field key up!
I/System.out: game name field key typed!
I/System.out: game name field key down!
I/System.out: game name field key up!
I/System.out: game name field key typed!

here is my code:

public class AccountScreen implements Screen {


final PieTherapy game;
private Stage stage;

private TextField gameNameField;

public AccountScreen(final PieTherapy game) {
    this.game = game;
    initialize();
}

private void initialize() {

    Viewport vp = new StretchViewport(PieTherapy.WORLD_WIDTH, PieTherapy.WORLD_HEIGHT, game.cam);
    stage = new Stage(vp);

    Gdx.input.setInputProcessor(stage);

    TextField.TextFieldStyle tfs = new TextField.TextFieldStyle();
    tfs.font = game.fontTitle;
    tfs.fontColor = Color.WHITE;
    tfs.background = new TextureRegionDrawable(new TextureRegion(game.assets.get("menus/textline.png", Texture.class)));
    tfs.focusedBackground = new TextureRegionDrawable(new TextureRegion(game.assets.get("menus/textline-selected.png", Texture.class)));
    tfs.cursor = new TextureRegionDrawable(new TextureRegion(game.assets.get("menus/cursor.png", Texture.class)));

    gameNameField = new TextField("", tfs);
    gameNameField.setWidth(PieTherapy.WORLD_WIDTH * .80f);
    gameNameField.setFocusTraversal(true);
    gameNameField.setPosition(PieTherapy.WORLD_WIDTH *.05f, game.WORLD_HEIGHT * .68f);
    // see if the player information has already been entered (edit mode)
    gameNameField.setText(game.primaryPlayer.gameName);
    gameNameField.addListener(new InputListener(){
        @Override
        public void touchUp (InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("game name field touch up!");
        }
        @Override
        public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) {
            System.out.println("game name field touch down!");
            return true;
        }

        @Override
        public boolean keyDown(InputEvent event, int keycode) {
            System.out.println("game name field key down!");
            return super.keyDown(event, keycode);
        }

        @Override
        public boolean keyUp(InputEvent event, int keycode) {
            System.out.println("game name field key up!");
            return super.keyUp(event, keycode);
        }

        @Override
        public boolean keyTyped(InputEvent event, char character) {
            System.out.println("game name field key typed!");
            return super.keyTyped(event, character);
        }
    });

    gameNameField.getOnscreenKeyboard().show(true);
    gameNameField.setCursorPosition(gameNameField.getText().length());

    stage.addActor(gameNameField);

    stage.setKeyboardFocus(gameNameField);
}

@Override
public void show() {

}

@Override
public void render(float delta) {
    Gdx.gl.glClearColor(0, 0, 0f, 1);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    game.batch.begin();
    game.font.draw(game.batch, "Your name in the game! You can stick with the\nautomatically generated" +
                    "one or change to your own.\n Red: name is not available, " +
                    "green: available.",
            PieTherapy.WORLD_WIDTH *.36f,
            PieTherapy.WORLD_HEIGHT *.93f);

    game.batch.end();

    update(delta);
}

private void update(float delta) {

    stage.act(delta);

    stage.draw();

    game.batch.begin();

    game.batch.end();

}

@Override
public void resize(int width, int height) {

}

@Override
public void pause() {

}

@Override
public void resume() {

}

@Override
public void hide() {

}

@Override
public void dispose() {

}
}

LibGDX Version: 1.9.6 RoboVM Version (MobiDevelop): 2.3.1

I think I can always minimize my own on-screen keyboard ...

+6
1

, - . , , iOS.

- -, , , .

+2

All Articles