Creating a text input field

How to

Include a user-editable text field in your application.

Solution

Construct the text input object in your class

var myTextInput:TextInput = new TextInput();

Set the attributes of your text input object

// Set object position
myTextInput.x = 200;
myTextInput.y = 200;

// Set object size
myTextInput.width = 350;
myTextInput.height = 200;

// Optional: Set prompt text for empty field
myTextInput.prompt = "Type Here!";

// Optional: Set when the icon to clear the text field appears
myTextInput.clearIconMode = TextInputIconMode.UNLESS_EDITING;

Build requirements

You must include the following classes in your class:

import qnx.fuse.ui.text.TextInput;

or

import qnx.fuse.ui.text.TextArea;

You can optionally include the following class:

import qnx.fuse.ui.text.TextInputIconMode;

You can use the qnx.fuse.ui.text.TextArea class instead of the TextInput class if your application requires multiple lines of input.

Discussion

When you create a text input field, you declare the  TextInput or TextArea variable and then set its attributes. You can reference the current text typed into the field by referencing the object's text  property.