TextEdit

From Xojo Documentation

Class (inherits from RectControl)

The base class for TextField and TextArea. TextEdit is an abstract class and should not be instantiated directly. Use the TextField and TextArea controls in windows. ListBox.ActiveCell is a TextEdit object.

Events
Close DragOver MouseEnter
ConstructContextualMenu DropObject MouseExit
ContextualMenuAction EnableMenuItems MouseMove
DragEnter KeyDown MouseWheel
DragExit KeyUp Open


Properties
AcceptTabs fa-lock-32.png Left SelText
Active fa-lock-32.png LiveUpdate TabIndex
Alignment LockBottom TabStop
AutoDeactivate LockLeft Text
AutomaticallyCheckSpelling LockRight TextColor
BackColor LockTop TextFont
Bold Mask TextSize
Border fa-lock-32.png MouseCursor TextUnit
DataField MouseX fa-lock-32.png Top
DataSource MouseY fa-lock-32.png Transparent
Enabled Name TrueWindow fa-lock-32.png
Format PanelIndex Underline
Handle fa-lock-32.png Parent UseFocusRing
Height ReadOnly Visible
HelpTag Scope fa-lock-32.png Width
Index fa-lock-32.png SelLength Window fa-lock-32.png
Italic SelStart


Methods
AcceptFileDrop Close Refresh
AcceptPictureDrop Copy RefreshRect
AcceptRawDataDrop DrawInto ScrollPositionX
AcceptTextDrop InsertionPosAtXY SelectAll
AppendText Invalidate SetFocus
CharPosAtLineNum LineNumAtCharPos SetString
CharPosAtXY Paste

Class Constants

The following class constants can be used to specify the value of the Alignment property.

Class Constants Description
AlignDefault Default alignment, currently the same as Left alignment.
AlignLeft Left alignment.
AlignCenter Center alignment.
AlignRight Right alignment.

Notes

TextEdit is the base class for both TextArea and TextField. TextEdit is an abstract class and it is not intended for instantiation. Use TextArea for multiline and styled controls and TextField for single line text fields.

Execution order of MenuHandlers

The intrinsic control menu handlers (such as TextField.SelectAll) are handled after any user-defined menu handlers on the TextField subclass (if it was subclassed). This means that if you have a SelectAll handler on the Window of the TextField, it will no longer be called when the TextField has focus, because the TextField will now handle it first. In this situation, create a TextField subclass that defines its own SelectAll handler, and handle the desired behavior there.

Masks

Use the Mask property to filter user input on a character-by-character basis and add formatting characters. For example, a mask for a Telephone number field can add parentheses, spaces, and dashes as literals, that are used for formatting, and the digit mask symbol '#' to restrict entry to numbers only.

The following table shows the characters that you can use to define a mask.

Mask Character Description
# The single digit placeholder. The user can type only a digit (numeric) character in this position. For example, the mask "(###) ###-####" accepts the entry 5551212121" and returns "(555) 121-2121".
. Decimal placeholder.

The decimal placeholder that is actually used is specified in the user's International settings. The character is treated as a literal (formatting) character for masking purposes. For example, the mask "##.##" accepts the entry "2344" and returns "23.44" (for US systems).

, Thousands separator.

The thousands separator that is actually used is specified in the user's International settings. The character is treated as a literal (formatting) character for masking purposes. For example, the mask "####,###" accepts the entry "123456" and returns "123,356".

: Time separator.

The time separator that is actually used is specified in the user's International settings. The character is treated as a literal (formatting) character for masking purposes.

/ Date separator.

The date separator that is actually used is specified in the user's International settings. The character is treated as a literal (formatting) character for masking purposes. For example, the mask "99/99/\2099" accepts the entry "123109" and returns "12/31/2009". The "\20" enters the default century and decade and only accepts the year in the first decade of the century.

\ Mask escape character.

Treats the next character in the mask as a literal. The escape character enables you to use the '#', '&', 'A', '?' (and so on) characters in the mask. The escapted character is treated as a literal (formatting) character. For example, the mask "\C\C-9999" accepts the entry "1234" and returns "CC-1234".

& Character or space placeholder. It accepts one character.

Valid values are the ASCII characters 32-126 and the non-ASCII characters 128-255. For example, the mask "&&-99999" accepts "li20520" and returns "li-20520".

C Character or space placeholder, where entry is optional. It operates like the '&' placeholder. For example, the mask "CCCC-CC" formats "1233ed" as "1233-ed".
> Convert all the characters that follow to uppercase.

Uppercasing works beyond the ASCII range where appropriate, e.g., ü becomes Ü. For example, the mask ">&&-#####" accepts the string "li20520" and returns "LI-20520".

< Convert all the characters that follow to lowercase.

Lowercasing works beyond the ASCII range where appropriate, e.g., Ü becomes ü.

A Alphanumeric character placeholder, where entry is mandatory.

For example, the spec "AAA" specifies three alphanumeric characters.

a Alphanumeric character placeholder, where entry is optional.
0 The literal "0" (zero). For example, the mask "99.00" formats the entry "22" as "22.00". The mask "\C\C0-9999" accepts the entry "1234" and returns it as "CC0-1234". The mask "##,###.00" accepts the entry "12345" and returns "12,345.00". The mask "99.00" accepts "21" and returns "21.00".
9 A Single (numeric) digit.
? Alphabetic placeholder. Entry is optional. For example, the mask "???" accepts three alphabetic characters. It rejects numeric characters.
Any literal All other symbols are displayed as literals for formatting purposes. For example, the mask "99[9]" accepts the entry "333" and returns "33[3]".
~ Reserved for future use. If you use "~" it will trigger an exception error. Use \~ instead.

Examples

Mask Description
999,999.99 Formats 2222222223 as "2222,222.23" (Using the US thousands separator.
99.00 Formats "22" as "22.00."
###-##-#### //US Social Security number. Fomats "111111111" as 111-11-1111.
TextField1.Mask = "###-##-####"
TextField1.Mask = "(###) ###-####" // US Phone number, with area code

If the user tries to enter a character that is prohibited by the mask, a ValidationError event occurs. The character that the user attempted to enter and the character position is passed to the ValidationError event, where you can handle the keystroke as you like.

To cancel the Mask, set it to the empty string:

TextField1.Mask = ""

See Also

RectControl, TextArea, TextField classes.