Skip to content

Latest commit

 

History

History
151 lines (105 loc) · 9.08 KB

File metadata and controls

151 lines (105 loc) · 9.08 KB
layout docpage
title Jewel TextInput
description The Jewel TextInput is a control for single-line text field
permalink /component-sets/jewel/textinput

< Jewel Components list

Jewel TextInput

Reference

Available since version 0.9.4.

Class Extends
org.apache.royale.jewel.TextInput{:target='_blank'} org.apache.royale.jewel.supportClasses.textinput.TextInputBase{:target='_blank'}

Note: This component is currently only available for JavaScript.

Overview

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

For a 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:

<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width="100%" height="300" src="assets/jewel/jewel_textinput/index.html"></iframe>

code here{:target='_blank'}

Relevant Properties and Methods

Check the reference of org.apache.royale.jewel.TextInput{:target='_blank'} 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 component has change event of type org.apache.royale.events.Event{:target='_blank'}. This event is dispatched when text in the component changes through user input. Note that programatic changes do 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 uses 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 adds text to the input field, the message "new text is: " plus the text added appears 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 component does not have beads for View, Controller or Model in the JavaScript platform.

On the other hand, you can add to it beads specially 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{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to make all text change to lower case.
MaxNumberCharacters{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to set the maximun number of characters the text field can hold.
PasswordInput{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to secure the text field by masking the input as it is typed.
Restrict{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to use a regular expresion pattern to validateo user input.
SearchFilterForList{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to filter options in other Jewel List components used in combination with the text input component.
TextPrompt{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to place a string into the input field when there is no value associated with the text property.
UpperCase{:target='_blank'} org.apache.royale.core.IBead{:target='_blank'} Add this bead to make all text change to upper case.

Common Beads

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

More examples

Related controls

Related Jewel components are: