Textfield widgets allow the user to enter text.
Textfield widgets have the following attributes/properties:
| Property | Description | Required | In template | Default | Script |
|---|---|---|---|---|---|
| name | The name of the widget | No | N/A | _textfieldnn | Read-only |
| x | Horizontal screen position | Yes | No | N/A | Yes |
| y | Vertical screen position | Yes | No | N/A | Yes |
| width | Width of the widget | No | Yes | None | Yes |
| height | Height of the widget | No | Yes | None | Yes |
| template | Template to base the widget on | No | N/A | N/A | No |
| visible | Whether or not the widget is shown | No | N/A | True | Yes |
| background | The image file to display as the textfield background | No | Yes | None | Yes |
| backgroundfocus | The image file to display as the textfield background when the textfield has the focus | No | Yes | None | Yes |
| backgroundstyle | How to draw the image (tiled/normal) | No | Yes | normal | Yes |
| font | Truetype font file to use | Yes* | Yes | N/A | Yes |
| fontcolor | Colour to use for the text | No | Yes | #FFFFFF | Yes |
| fontsize | The size of the text (in points) | No | Yes | 16 | No |
| borderx | Horizontal amount of border to leave around the outside of the textfield | No | Yes | 0 | Yes |
| bordery | Vertical amount of border to leave around the outside of the textfield | No | Yes | 0 | Yes |
| maxlength | The maximum length of the text | No | Yes | 255 | Read-only |
| validchars | Regular expression to verify entered characters, eg. [0-9] would allow only numbers to be entered. Does not affect setting the text property directly. If empty, no validation is done. | No | Yes | (empty) | Yes |
| text | The text entered into the textfield | Not in XML | N/A | (empty) | Yes |
| cursorpos | Cursor position (0 to length of text). If set to greater than the length of the text, the cursor will be placed at the end of the text. | Not in XML | N/A | N/A | Yes |
*: Must be specified either in the template or in widget itself
The following methods are supported by textfield widgets:
| Method | Description |
|---|---|
| setfocus() | Give focus to the textfield. |