Skip to main content
gamedev.net
🔒 Locked

textbox

Started by Tech19 Apr 27, 2004 at 3:57 PM 0 replies 350+ views
Original Post
Tech19
Tech19
How can i go about display a text box on the screen which allows the user to enter a text string and then click ok and this string is stored in a variable. At the moment when my text box is displayed there are only the options ''Clear'' & ''Options'' none of which will allow me to save my string. Any help is greatly appreciated! I''m using j2me by the way, and its on a nokia 7210 emulator.
Zahlman
Zahlman
First, check what''s available under "Options".

To implement your own handling of things, though: what you need to do is add a Command to your TextBox. Then set an object to be the CommandListener for the TextBox (if you''re subclassing TextBox for implementing other stuff, then setting it to "this" will work just fine). Make sure the listening object implements the CommandListener interface, which consists of this one method:

public void commandAction(Command, Displayable);

The parameters are provided because several Displayables may have the same object as a Command listener, and thus several Commands might also be received. (The Displayables in question can even share Command objects).

In your commandAction implementation, you want to detect the combination of Command and Displayable that you''re looking for (your new "okCommand" or whatever you call it, and your TextBox instance) and provide the appropriate code (i.e. targetVariable = myTextBox.getString() ; ).


Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.