TextField

Textfield widgets allow the user to enter text.

Properties

Textfield widgets have the following attributes/properties:

PropertyDescriptionRequiredIn templateDefaultScript
nameThe name of the widgetNoN/A_textfieldnnRead-only
xHorizontal screen positionYesNoN/AYes
yVertical screen positionYesNoN/AYes
widthWidth of the widgetNoYesNoneYes
heightHeight of the widgetNoYesNoneYes
templateTemplate to base the widget onNoN/AN/ANo
visibleWhether or not the widget is shownNoN/ATrueYes
backgroundThe image file to display as the textfield backgroundNoYesNoneYes
backgroundfocusThe image file to display as the textfield background when the textfield has the focusNoYesNoneYes
backgroundstyleHow to draw the image (tiled/normal)NoYesnormalYes
fontTruetype font file to useYes*YesN/AYes
fontcolorColour to use for the textNoYes#FFFFFFYes
fontsizeThe size of the text (in points)NoYes16No
borderxHorizontal amount of border to leave around the outside of the textfieldNoYes0Yes
borderyVertical amount of border to leave around the outside of the textfieldNoYes0Yes
maxlengthThe maximum length of the textNoYes255Read-only
validcharsRegular 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.NoYes(empty)Yes
textThe text entered into the textfieldNot in XMLN/A(empty)Yes
cursorposCursor 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 XMLN/AN/AYes

*: Must be specified either in the template or in widget itself

Methods

The following methods are supported by textfield widgets:

MethodDescription
setfocus()Give focus to the textfield.

Events

The following events are triggered by textfield widgets:

EventDescription
OnChangeOccurs when the text is changed.
OnGotFocusOccurs when the textfield receives focus.
OnLostFocusOccurs when the textfield loses focus.