1

I just wonder what will be the best solution for receiving text input from user in PlayN. I didn't find anything that i can use to achieve this, i think that the best solution will be to render something like HTML inputs to write a text, but it will be not that simple because we need to be able to use in example virtual keyboard from android (on android platform) and regular keyboard on HTML backend. Even then i think it will be very difficult (or impossible) to evoke android keyboard in game...

I'm thinking about creating a widget in tripleplay UI library (because i will use it), but this will end with rendering virtual keyboard on screen for user inputs.. buttons from a-z etc...

I wonder is there any better solution for this, or i need to implement something like i wrote above (like tripleplay widget)?

btk
  • 21
  • 1

1 Answers1

2

There is already a Tripleplay widget for receiving text input called Field.

However, it is very primitive and does not yet work on mobile platforms (it will work on an Android device with a hardware keyboard). We need to provide an API in PlayN to display the virtual keyboard, but until then there's no way for it to trigger the display of the virtual keyboard.

I don't recommend using this for any substantial text input, however. It doesn't (and never will) support cut and paste, or language input methods, or anything of the other extremely complex features that users expect for text input.

I would like to add an API to PlayN like:

Keyboard.requestTextInput(String label, Callback<String> callback)

which would pop up the virtual keyboard, with an attached (native) text box, and allow the user to enter a single line of text using all of the machinery of the platform's native text entry support. This will allow them to cut-and-paste, and use language input methods, and provide an experience with which they are comfortable on the platform in question.

If your game needs more sophisticated text input (like a chat interface, or the ability to take pages of notes), you will probably have to create a separate interface for each platform that you wish to support, using native multiline text editing widgets and then "wire" those into your PlayN game. This will be more complicated than can be described in a simple SO answer, so you'll have to do some research and learn how PlayN manages the display on each of the backends that you wish to support.

samskivert
  • 3,694
  • 20
  • 22
  • thanks for replay... i just try Field but it is not working even in JAVA.. when i clicked and i try to type something it wont display....I am wonder if are they any plans for you proposition for virtual keybord with API to PlayN "Keyboard.requestTextInput(String label, Callback callback)" and if so... when it will be aviable... I think that this kind of usability will be needed.. A lot of games will use text inputs from users.. like characters name and more... – btk Mar 01 '12 at 12:34
  • sorry it work well with a hardware keyboard (just forget to add keyboard().setListener(klistener);).. but my further question is open (about virtual keybord with API to PlayN):) – btk Mar 01 '12 at 13:06