Text Input with libGdx

I'm working on a menu system with libGdx and I'm not sure how to handle Text Input.  I was planning to manage simple buttons like normal drawable sprites, but I'm not sure how to handle text boxes.  Obviously any text box needs to bring up the soft keyboard, but I'm not sure how to trigger it and how to respond to the input.

Is there anything in libGdx or ODK that makes this easier?  How can I go about getting text input within my libGdx game? Thanks.

Comments

  • mjoynermjoyner Posts: 168Member
    libGDX has a TextField class. This may be what you are looking for.
  • ClowenClowen Posts: 46Member
    I have tried using the TextField in a scene2d Stage setup.  But currently it just shows up, there's no actions happening. Using the touchpad to try to click on it does nothing. Am I missing something, do I need to set up some kind of listeners for the TextField or Stage?
  • mjoynermjoyner Posts: 168Member
    edited March 2013
    Well, you need to set the GDX input processor with your stage instance as a starting point.

    Gdx.input.setInputProcessor(stage_instance);

    If you don't the stage never receives input events from anything.

    Then, according to the wiki, there is also "TextInputListener" that can also be used:

    http://code.google.com/p/libgdx/wiki/InputTextInput

    Also:
    Gdx.input.setOnscreenKeyboardVisible(true);

    Also:

    http://code.google.com/p/libgdx/wiki/InputEvent
    Post edited by mjoyner on
  • ClowenClowen Posts: 46Member
    Thank mjoyner, looks like it's all working as expected.
Sign In or Register to comment.