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.
Name | Usage | Type | Default | Accessibility |
---|---|---|---|---|
password | Tag and JS | Boolean | false | read-write |
Description. Indicates whether or not this input text masks each of its character as an asterisk. | ||||
resizable | Tag and JS | Boolean | false | read-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.
<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.
As another example, the code in Listing 3.4 shows an input text component used as a password box.
<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