Mobile Text Field

From Xojo Documentation

A Text Field control provides a single-line field for entering text. When the user taps in the field, the on-screen keyboard automatically appears. All standard iOS editing features are available, including copy/paste and auto-correct.

Below is a list of commonly used events and properties. Refer to MobileTextField in the Language Reference for the complete list.


TextChanged - Called each time the text changes. This means it may be called many times as the user is typing into the field.


Enabled - A boolean that indicates if the text field is enabled and can have text entered or disabled and cannot have text entered or selected.

InputType - Lets you control the type of on-screen keyboard that is displayed when the user taps in the field. By default the full keyboard is displayed, but there are many other keyboards that are optimized for entering numbers, URLs, phone numbers, emails, etc. You change the type by using the iOSKeyboardTypes enumeration.

Password - A boolean that enables password mode for the field. This means that the text is replaced with dots after each character has been typed.

PlaceHolder - Used to specify placeholder text that is displayed when the field is empty. This text is used to provide instructions or help and displays in a lighter color to distinguish it from text that is actually entered into the field. The text itself is not in the field and does not have to be cleared before the user begins typing.

Text - This is the text that is typed in the field. You can use this property to set the default text that appears or check this property to get the text that has been typed.

TextAlignment, TextColor, TextFont - These properties change the alignment, color and size of the text.


Mobile Text Field

To populate text in a TextField, use the Text propery, which you can set using the Inspector or with code such as this:

NameField.Text = "Bob Roberts"

To get the text that was typed, you also use the Text property. This gets the text in the NameField:

Var userName As String
userName = NameField.Text

To get the value as it is being changed, use the TextChanged event handler and the Text property. This code updates a label with the text being entered in a text field:

NameLabel.Text = Me.Text
Mobile Keyboard Decimal

Some types of text fields may contain specific information, so it makes sense to change the input type. For example, if want the user to enter an amount of money, you might want to use the Decimal.

You can set the InputType in the Inspector or with code like this:

AmountField.InputType = MobileTextField.InputTypes.Decimal

See Also

MobileTextField class; UserGuide:Mobile Text Area topic