Extends Text and Item

TextEdit

The text edit element is for editable text.

The TextEdit element is useful as the fundamental building block for richer text entry experiences. It handles scrolling, text selection and all the details needed for text entry, but displays the text without any visual decoration.

TextEdit {
    text: "Hello world" 
    size: 16
}

For a more complete text input control suitable for user entry fields, see Apple.TextField.

property String text

event accepted()

The text property contains the text currently being shown by the TextEdit. If you assign to this property it will set the text, just like a regular Text element.

As the text is edited, the text property will update with any changes. When the user finishes editing the text, the accepted event will fire. This happens when either the TextEdit loses focus, or the TextEdit has a wrapMode of SingleLine and the return or done keys are pressed.

property Bool enabled: true

property Bool editable: true

Controls whether the TextEdit is enabled and editable.

A disabled TextEdit is indistinguishable from a regular Text element. The text cannot be edited or selected.

An enabled TextEdit with the editable property disabled cannot be edited, but its text can be selected and copied.

property Float marginX: 0

property Float marginY: 0

Specifies the x and y margins to apply around the text.

function select(Int start, Int length)

function selectAll()

function clearSelection()

Select text in the TextEdit.

function ensureCursorVisible()

Scrolls the TextEdit, if necessary, so that the edit cursor is visible.

property Bool autocorrect: true

property TextEdit.KeyboardType keyboardType: .Default

property TextEdit.KeyboardAppearance keyboardAppearance: .Light

property TextEdit.AutocapitalizationType autocapitalizationType: .Sentence

These properties adjust the appearance and behavior of the keyboard shown for text entry into this TextEdit on mobile devices.

When autocorrect is true, the TextEdit will use text auto correction, otherwise text entry will not be autocorrected.

The autocapitalizationType property controls the autocapitalization behavior applied to the text entry on iOS and Android.

TextEdit.AutocapitalizationType.None

No automatic text capitalization.

TextEdit.AutocapitalizationType.Word

Automatic capitalization of the first letter of each word.

TextEdit.AutocapitalizationType.Sentence

Automatic capitalization of the first letter of each sentence.

TextEdit.AutocapitalizationType.All

Automatic capitalization of all characters.

The keyboardType property controls the type of keyboard displayed. On some devices, different keyboard type values will result in the same keyboard being shown.

TextEdit.KeyboardType.Default

The default keyboard for the current input method.

TextEdit.KeyboardType.ASCII

A keyboard that displays standard ASCII characters.

TextEdit.KeyboardType.NumbersAndPunctuation

The numbers and punctuation keyboard.

TextEdit.KeyboardType.URL

A keyboard optimized for URL entry. This keyboard type prominently features the period (".") and slash ("/") characters and the ".com" string.

TextEdit.KeyboardType.NumberPad

A numeric keypad designed for PIN entry. This keyboard type prominently features the numbers 0 through 9.

TextEdit.KeyboardType.PhonePad

A keypad designed for entering telephone numbers. This keyboard type prominently features the numbers 0 through 9 and the "*" and "#" characters.

TextEdit.KeyboardType.NamePhonePad

A keypad designed for entering a person’s name or phone number.

TextEdit.KeyboardType.EmailAddress

A keyboard optimized for entering email addresses. This keyboard type prominently features the at ("@"), period (".") and space characters.

TextEdit.KeyboardType.DecimalPad

A keyboard with numbers and a decimal point.

TextEdit.KeyboardType.Twitter

A keyboard optimized for Twitter text entry, with easy access to the at ("@") and hash ("#") characters.

TextEdit.KeyboardType.WebSearch

A keyboard optimized for web search terms and URL entry. This keyboard type prominently features the space and period (".") characters.

The keyboardAppearance property controls the look of the keyboard on iOS devices. On Android it has no effect.

TextEdit.KeyboardAppearance.Light

Specifies a keyboard appearance suitable for a light UI look.

TextEdit.KeyboardAppearance.Dark

Specifies a keyboard appearance suitable for a dark UI look.