< Jewel Components list

Jewel TextInput

Reference

Available since version 0.9.4.

Class Extends
org.apache.royale.jewel.TextInput org.apache.royale.jewel.supportClasses.textinput.TextInputBase

Note: This component is currently only available for JavaScript.

Overview

The Jewel TextInput implements the jewel control for single-line text field. It dispatches a change event when the user input text.

For multi line text input control see TextArea

Example of use

In MXML declare a TextInput like this:

<j:TextInput/>

In ActionScript we can do the same in the following way:

var textInput:TextInput = new TextInput();
parent.addElement(textInput);

where parent is the container where the control will be added.

Here is an example of the default text input:

code here

Relevant Properties and Methods

Check the Reference of org.apache.royale.jewel.TextInput for a more detailed list of properties and methods.

Properties

PROPERTY Type Description
text String The text inside the text field.
html String The html text inside the text field.

Methods

None.

Relevant Events

The TextInput has change event of type org.apache.royale.events.Event. This event is dispatched when text in the control changes through user input. Notice that programatic changes will not trigger this event.

You can attach callback listeners to the change event in MXML as follows:

<j:TextInput change="changeHandler(event)"/>

the change event will use the changeHandler callback function you provide in ActionScript:

<fx:Script>
    <![CDATA[      
        private function changeHandler(event:Event):void {
            trace("new text is: " + event.target.text);
        }
    ]]>
</fx:Script>

When the user introduce text in the input field, the message “new text is: “ plus the text introduced will appear in the console log.

In ActionScript we can add an event handler this way:

var textInput:TextInput = new TextInput();
textInput.addEventListener('change', changeHandler);
parent.addElement(textInput);

Relevant Beads

Unlike other components in Royale, the Jewel TextInput does not have beads for View, Controller or Model in the Javascript platform.

On the other hand, you can add to it beads specialy crafted for this control or other common Jewel control beads (shared with other controls) to provide more functionality.

TextInput Beads

Bead Type Implementation Description
LowerCase org.apache.royale.core.IBead Add this bead to makes all text change to lower case.
MaxNumberCharacters org.apache.royale.core.IBead Add this bead to set the maximun number of characters the text field can hold.
PasswordInput org.apache.royale.core.IBead Add this bead to secures the text field by masking the input as it is typed.
Restrict org.apache.royale.core.IBead Add this bead to use a regular expresion pattern to validate input from user.
SearchFilterForList org.apache.royale.core.IBead Add this bead to filter options in other Jewel List component used in combo with the text input.
TextPrompt org.apache.royale.core.IBead Add this bead to place a string into the input field when there is no value associated with the text property.
UpperCase org.apache.royale.core.IBead Add this bead to makes all text change to upper case.

Common Beads

Bead Type Implementation Description
Disabled org.apache.royale.core.IBead This bead lets you disable and enable a Jewel control.
SizeControl org.apache.royale.core.IBead Add this bead to give the Jewel control a custom size.
ToolTip org.apache.royale.core.IBead Add this bead to enable floating a text string over the control when the user hovers the mouse cursor over it.

More examples

Other related Jewel components are: