public class TextBox extends Widget:
Editable text field.
The class now owns a real text-editing model: caret position, selection, read-only mode and insertion/deletion helpers. The native backend still has to relay keyboard and mouse events into this API for the on-screen control to become interactive.
field = TextBox("Hello")
field.insertText(" world")
field.selectAll()| Modifier and Type | Member | Description |
|---|---|---|
| public static readonly | ECHO_NORMALECHO_NORMAL as String = "normal" |
Displays the field content as plain text. |
| public static readonly | ECHO_PASSWORDECHO_PASSWORD as String = "password" |
Masks the field content while keeping the real value in `text`. |
| Modifier and Type | Member | Description |
|---|---|---|
| public property | caretPositioncaretPosition as Int |
Caret insertion position. |
| public property | echoModeechoMode as String: |
Controls how the text is rendered. |
| public property | isReadOnlyisReadOnly as Boolean |
Disables edition while keeping selection and focus support. |
| public property | maxLengthmaxLength as Int |
Maximum accepted characters. |
| public property | paddingXpaddingX as Int |
Horizontal text padding. |
| public property | placeholderplaceholder as String |
Placeholder shown when the field is empty. |
| public property | selectionEndselectionEnd as Int |
Selection active edge. |
| public property | selectionStartselectionStart as Int |
Selection anchor. |
| public property | texttext as String: |
Current field content. |
| public property | textAligntextAlign as String |
Horizontal text alignment. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | clearSelectionclearSelection() as Void: |
Clears the current selection and keeps the caret at its position. |
| public | deleteBackwarddeleteBackward() as Boolean: |
Deletes the current selection or the character before the caret. |
| public | deleteForwarddeleteForward() as Boolean: |
Deletes the current selection or the character after the caret. |
| public | hasSelectionhasSelection() as Boolean: |
Returns true when a selection is active. |
| public | insertText | Inserts text at the caret position or replaces the current selection. |
| public | moveCaretLeftmoveCaretLeft(extendSelection as Boolean = false) as Void: |
Moves the caret to the left. |
| public | moveCaretRightmoveCaretRight(extendSelection as Boolean = false) as Void: |
Moves the caret to the right. |
| public override | paintpaint(painter as Painter) as Void: |
Paints the field with antialiasing, selection and caret. |
| public | select | Updates the current selection range. |
| public | selectAllselectAll() as Void: |
Selects the whole field content. |
| public | setCaretsetCaret(position as Int) as Void: |
Moves the caret to a given position. |