TextInput
Handles keyboard text input and cursor navigation.
This class manages text editing operations including text insertion, deletion, selection, and cursor movement. It works in conjunction with the backend's text input system.
Instance Members
allowMovingCursor: BoolWhether cursor movement with arrow keys is allowed.
multiline: BoolWhether multiline text input is enabled. When true, Enter key creates new lines instead of submitting.
text: StringThe current text content.
selectionStart: IntThe start position of the text selection (cursor position when no selection).
selectionEnd: IntThe end position of the text selection (same as selectionStart when no selection).
delegate: TextInputDelegateOptional delegate for custom text navigation behavior.
start(text: String, x: Float, y: Float, w: Float, h: Float, ?multiline: Bool = false, ?selectionStart: Int = -1, ?selectionEnd: Int = -1, ?allowMovingCursor: Bool = false, ?delegate: TextInputDelegate = null): VoidStart text input.
| Name | Type | Default | Description |
|---|---|---|---|
text |
String | Initial text content | |
x |
Float | X position of the input area in screen coordinates | |
y |
Float | Y position of the input area in screen coordinates | |
w |
Float | Width of the input area | |
h |
Float | Height of the input area | |
multiline |
Bool | false |
Whether to allow multiline input |
selectionStart |
Int | -1 |
Initial selection start position (-1 for end of text) |
selectionEnd |
Int | -1 |
Initial selection end position (-1 for no selection) |
allowMovingCursor |
Bool | false |
Whether to allow cursor movement with arrow keys |
delegate |
TextInputDelegate | null |
Optional delegate for custom navigation behavior |
stop(): VoidStop text input and release resources.
Update the current text selection.
| Name | Type | Default | Description |
|---|---|---|---|
selectionStart |
Int | New selection start position | |
selectionEnd |
Int | New selection end position | |
inverted |
Bool | (optional) | Whether the selection is inverted (cursor at start) |
Append text at the current cursor position. Replaces any selected text.
| Name | Type | Description |
|---|---|---|
text |
String | Text to append |
space(): VoidInsert a space character at the cursor position.
backspace(): VoidDelete the character before the cursor or the selected text.
moveLeft(): VoidMove the cursor one character to the left. If Shift is pressed, extends the selection.
moveRight(): VoidMove the cursor one character to the right. If Shift is pressed, extends the selection.
moveUp(): VoidMove the cursor one line up. If Shift is pressed, extends the selection.
moveDown(): VoidMove the cursor one line down. If Shift is pressed, extends the selection.
enter(): VoidHandle Enter key press. In multiline mode, inserts a newline. In single-line mode, triggers the enter event.
kpEnter(): Voidescape(): VoidHandle Escape key press. Triggers the escape event and stops input.
lshiftDown(): VoidlshiftUp(): VoidrshiftDown(): VoidrshiftUp(): VoidlctrlDown(): VoidlctrlUp(): VoidrctrlDown(): VoidrctrlUp(): VoidlmetaDown(): VoidlmetaUp(): VoidrmetaDown(): VoidrmetaUp(): VoidunbindEvents(): VoidPrivate Members
inputActive: BoolexplicitPosInLine: IntexplicitPosLine: IntlshiftPressed: BoolrshiftPressed: BoollctrlPressed: BoolrctrlPressed: BoollmetaPressed: BoolrmetaPressed: BoolinvertedSelection: Boolupdate event
| Name | Type |
|---|---|
text |
String |
emitEnter(): Voidenter event
emitEscape(): Voidescape event
selection event
| Name | Type |
|---|---|
selectionStart |
Int |
selectionEnd |
Int |
emitStop(): Voidstop event
Get the position in the current line, from the given global position in text
| Name | Type |
|---|---|
globalPos |
Int |
| Returns |
|---|
| Int |
Get the current line (starts from 0) from the given global position in text
| Name | Type |
|---|---|
globalPos |
Int |
| Returns |
|---|
| Int |
numLines(): Int| Returns |
|---|
| Int |
| Name | Type |
|---|---|
lineNumber |
Int |
lineOffset |
Int |
| Returns |
|---|
| Int |
new(): VoidMetadata
| Name | Parameters |
|---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:allow |
ceramic.App |