Class

MobileTextField


Description

A single-line text field for text.

Enumerations

MobileTextField.BorderStyles

BorderStyles

The various styles that can be set for the border of the control.

Enum

Description

None

The field has no border.

Rectangle

The field has a rectangular border.

Bezel

The field border makes the field appear inset.

Rounded

Like the Rectangle style but with slightly rounded corners.

MobileTextField.InputTypes

InputTypes

The various of keyboards that can be displayed when the control has focus.

Enum

Android Description

iOS Description

Default

Standard text entry.

Standard text entry.

NumbersAndPunctuation

Allows entering signed numbers.

For entering numbers that may include formatting.

URL

For entering URLs.

For entering URLs.

Numbers

For entering only numbers. No decimals or any punctuation.

For entering only numbers. No decimals or any punctuation.

Phone

For entering phone numbers.

For entering phone numbers.

NamePhone

Toggles between Default and Phone.

Toggles between Default and Phone.

Email

For entering email addresses.

For entering email addresses.

Decimal

Numbers only but includes the decimal.

Numbers only but includes the decimal.

Twitter

Same as Default but no text substitutions.

Like Default but includes the @ and # characters.

WebSearch

Same as Default but no text substitutions.

Like Default but changes the Done button to Go.

MobileTextField.ReturnCaptions

ReturnCaptions

The various of captions that can be used with the Return key on the keyboard.

Enum

Default

Go

Join

NextCaption

Route

Search

Send

Done

EmergencyCall

ContinueCaption

Property descriptions


MobileTextField.AccessibilityHint

AccessibilityHint As String

The accessibility hint is a longer description that is read aloud when VoiceOver is enabled.

Me.AccessibilityHint = "Click to calculate the value and display the next screen."

MobileTextField.AccessibilityLabel

AccessibilityLabel As String

The accessibility label of of a control is a short name that is read aloud when VoiceOver is enabled.

Me.AccessibilityLabel = "Calculate the value."

MobileTextField.Alignment

Alignment As MobileTextControl.Alignments

Specifies the alignment of the text in the control.

This code in the control's Opening event sets the alignment to justified:

Me.Alignment = MobileTextControl.Alignments.Justified

MobileTextField.AllowAutoCorrection

AllowAutoCorrection As Boolean

If True, misspelled words will be automatically corrected as the user types.

Important

This is supported for iOS only.


MobileTextField.AllowSpellChecking

AllowSpellChecking As Boolean

If True, misspelled words will be underlined in red.


MobileTextField.BorderStyle

BorderStyle As BorderStyles

The style in which the border of the textfield will be drawn.

Any BorderStyle other than Rounded makes the TextField content background transparent.

Important

This is supported for iOS only.

TextField1.BorderStyle = MobileTextField.BorderStyles.Rounded

MobileTextField.ControlCount

ControlCount As Integer

The number of child controls in the control.

This property is read-only.

Important

This is supported for iOS only.


MobileTextField.Enabled

Enabled As Boolean

Indicates whether the control is enabled or disabled.

Disable the button:

Button1.Enabled = False

MobileTextField.Height

Height As Integer

The height of the control.

This property is read-only on iOS.


MobileTextField.Hint

Hint As String

Non-selectable, non-editable text that appears when the textfield is empty.

The purpose of the hint is to give the user an idea of what information the field is expecting. This is particularly useful if the field does not have an associated label.

LastNameField.Hint = "Last Name"

MobileTextField.InputType

InputType As InputTypes

Indicates the type of data to be input so that the mobile device can display the appropriate keyboard.

PhoneField.InputType = MobileTextField.InputTypes.Phone

MobileTextField.Left

Left As Integer

The left position of the control.

This property is read-only on iOS.


MobileTextField.LockBottom

LockBottom As Boolean

Determines whether the bottom edge of the control should stay at a set distance from the bottom edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockBottom = True

MobileTextField.LockLeft

LockLeft As Boolean

Determines whether the left edge of the control should stay at a set distance from the left edge of the parent control, if there is one, or the owning screen.

LockLeft and Locktop default to True when you add a new control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockLeft has no effect unless LockRight is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockLeft = True

MobileTextField.LockRight

LockRight As Boolean

Determines whether the right edge of the control should stay at a set distance from the right edge of the parent control, if there is one, or the owning screen.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockRight = True

MobileTextField.LockTop

LockTop As Boolean

Determines whether the top edge of the control should stay at a set distance from the top edge of the parent control, if there is one, or the owning screen.

LockTop and LockLeft default to True when you add a control to a screen. Existing controls will be altered only if LockRight and/or LockBottom are not set. LockTop has no effect unless LockBottom is True.

Important

This property is not currently supported for iOS. Use constraints instead.

This property can be set in the control's Inspector. The following example sets it in code.

Me.LockTop = True

MobileTextField.Name

Name As String

The name of the control.


MobileTextField.Parent

Parent As MobileUIControl

The parent (sometimes called a "Super") class of the control.

This property is read-only.


MobileTextField.Password

Password As Boolean

If True, each character will be masked as it's entered.


MobileTextField.ReadOnly

ReadOnly As Boolean

If True, the contents of the field can be selected and copied but not changed.


MobileTextField.ReturnCaption

ReturnCaption As ReturnCaptions

The caption of the Return key when the keyboard is displayed.

The caption you choose will be displayed on the keyboard only when the user is using it with this specific TextField.

Important

This is supported for iOS only.

In the Opening event of a TextField, set Join as the caption for the return key:

Me.ReturnCaption = MobileTextField.ReturnCaptions.Send

MobileTextField.SelectedText

SelectedText As String

The text that is selected.


MobileTextField.SelectionLength

SelectionLength As Integer

The number of characters selected.


MobileTextField.SelectionStart

SelectionStart As Integer

The position of the first character in the selected text.


MobileTextField.Text

Text As String

The text in the control.

The following code sets the text of the control in any of its events:

Me.Text = "One ring to rule them all..."

MobileTextField.TextColor

TextColor As Color

The color of the text in the control.

Placed in any of the control's events, this code changes the text color to blue:

Me.TextColor = Color.Blue

MobileTextField.TextColor

TextColor As ColorGroup

The color of the text in the control.

Important

ColorGroups are not currently supported for Android.


MobileTextField.TextFont

TextFont As Font

A Font object that provides information about the control's font name, font size, and more.

From any of the control's events, this example changes the font:

Me.TextFont = Font.BoldSystemFont(20)

MobileTextField.TintColor

TintColor As ColorGroup

Changes a control's tint color.

Important

This is supported for iOS only.

On iOS, the following controls support TintColor:

Enum

Description

ProgressBar

The area indicating the value of the control will be drawn in the TintColor.

Slider

The area indicating the value of the control will be drawn in the TintColor.

TextArea

The cursor and text highlight color will be drawn in the TintColor.

TextField

The cursor and text highlight color will be drawn in the TintColor.


MobileTextField.Top

Top As Integer

The top position of the control.

This property is read-only on iOS.


MobileTextField.Visible

Visible As Boolean

Indicates whether the control is visible.

Make a button invisible:

Button1.Visible = False

MobileTextField.Width

Width As Integer

The width of the control.

This property is read-only on iOS.

Method descriptions


MobileTextField.AddConstraint

AddConstraint(constraint As iOSLayoutConstraint)

Adds a constraint to the control.

This constraint is used by child controls that have been added to this control.

Important

This is supported for iOS only.


MobileTextField.AddControl

AddControl(child As MobileUIControl)

Adds a child control to the control.

Important

This is supported for iOS only.


MobileTextField.ClearFocus

ClearFocus

Removes the focus from the control.

TextField1.ClearFocus

MobileTextField.ControlAt

ControlAt(index As Integer) As MobileUIControl

Gets the child control at the specified index.

Important

This is supported for iOS only.


MobileTextField.Controls

Controls As Iterable

Allows you to iterate through all the controls that have been added to this control.

Important

This is supported for iOS only.


MobileTextField.Handle

Handle As Ptr

The handle to the underlying native OS control.


MobileTextField.Refresh

Refresh

Marks the control so that it will be redrawn during the next event loop.

Call Refresh to force a Canvas to redraw itself:

Canvas1.Refresh

MobileTextField.RemoveConstraint

RemoveConstraint(constraint As iOSLayoutConstraint)

Removes a constraint from the control.

Important

This is supported for iOS only.


MobileTextField.RemoveControl

RemoveControl(child As MobileUIControl)

Removes the control from the control.

Important

This is supported for iOS only.


MobileTextField.SelectAll

SelectAll

Selects all text in the control.


MobileTextField.SetFocus

SetFocus

Sets the focus to the control.

TextField1.SetFocus

Event descriptions


MobileTextField.Closing

Closing

Called when the control's layout is closing.


MobileTextField.FocusLost

FocusLost

The MobileTextField has lost the focus.

Important

This event is currently supported for iOS only.


MobileTextField.FocusReceived

FocusReceived

The MobileTextField has received the focus and has a selection rectangle around it.

Important

This event is currently supported for iOS only.


MobileTextField.KeyDown

KeyDown(key As String) As Boolean

The user has pressed the key passed while the MobileTextField has the focus.

Returning True means the key is intercepted, preventing the key from actually reaching the control at all. This would be useful if you want to override the behavior of the tab key for example. Returning False means the key reaches the control.

Important

This is supported for iOS only.


MobileTextField.Opening

Opening

Called when the control's layout is opening.

This is where you typically put initialization code.

This example in the Opening event of a label sets its text to "Hello":

Me.Text = "Hello"

MobileTextField.ReturnPressed

ReturnPressed As Boolean

The Return key was pressed on the keyboard.

Note

On Android, returning False will dismiss the keyboard.


MobileTextField.SelectionChanged

SelectionChanged

The range of characters highlighted has changed.

Important

This event is supported for Android only.


MobileTextField.TextChanged

TextChanged

Called when the text changes from user entry. It is not called when the text is changed via code.

Update a label with the text as it is being entered:

NameLabel.Text = Me.Text

Compatibility

Mobile projects on all supported mobile operating systems.

See also

MobileTextControl parent class; MobileTextArea control