LzInputText

The LzInputText class is a direct descendant of LzText. An LzInputText object represents an editable text component. You can create an LzInputText object using the inputtext tag and you can set its password attribute to true to construct a password box.

Table 3.2 shows the attributes defined in the LzInputText class.

Table 3.2. The attributes defined in the LzInputText class
NameUsageTypeDefaultAccessibility
passwordTag and JSBooleanfalseread-write
 Description. Indicates whether or not this input text masks each of its character as an asterisk.
resizableTag and JSBooleanfalseread-write
 Description. Indicates if this input text is resizable.

The LzInputText class defines four methods:

setEnabled(enabled)

Specifies whether or not this input text is enabled. The user can edit the text of an enabled text input.

setHTML(html)

Sets the HTML flag on this text view.

setText(text)

Sets the text to display.

updateData()

Retrieves the contents of the text field for use by a datapath.

For example, Listing 3.3 shows an input text named inputField with a script that highlights the text in it.

Listing 3.3. Highlighting text
<canvas>
    <simplelayout axis="y"/>
    <view height="20" width="140" bgcolor="yellow" clip="true">
        <inputtext id="nameField">[Enter your name]</inputtext>
    </view>
    <script>
        var length = nameField.getText().length;
        nameField.setSelection(0, length);
    </script>
</canvas>

To run the program, use this URL:

http://localhost:8080/lps-4.0.x/app03/textTest3.lzx

The generated output is shown in Figure 3.3.

Figure 3.3. Using inputtext


As another example, the code in Listing 3.4 shows an input text component used as a password box.

Listing 3.4. Using password
<canvas>
    <view height="20" width="140" bgcolor="silver">
        <inputtext password="true">secret</inputtext>
    </view>
</canvas>

Try this example by directing your browser here:

http://localhost:8080/lps-4.0.x/app03/textTest4.lzx

The output is shown in Figure 3.4

Figure 3.4. The password box


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset