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: Bool
Whether cursor movement with arrow keys is allowed.
multiline: Bool
Whether multiline text input is enabled. When true, Enter key creates new lines instead of submitting.
text: String
The current text content.
selectionStart: Int
The start position of the text selection (cursor position when no selection).
selectionEnd: Int
The end position of the text selection (same as selectionStart when no selection).
delegate: TextInputDelegate
Optional 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): Void
Start 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(): Void
Stop 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(): Void
Insert a space character at the cursor position.
backspace(): Void
Delete the character before the cursor or the selected text.
moveLeft(): Void
Move the cursor one character to the left. If Shift is pressed, extends the selection.
moveRight(): Void
Move the cursor one character to the right. If Shift is pressed, extends the selection.
moveUp(): Void
Move the cursor one line up. If Shift is pressed, extends the selection.
moveDown(): Void
Move the cursor one line down. If Shift is pressed, extends the selection.
enter(): Void
Handle Enter key press. In multiline mode, inserts a newline. In single-line mode, triggers the enter event.
kpEnter(): Void
escape(): Void
Handle Escape key press. Triggers the escape event and stops input.
lshiftDown(): Void
lshiftUp(): Void
rshiftDown(): Void
rshiftUp(): Void
lctrlDown(): Void
lctrlUp(): Void
rctrlDown(): Void
rctrlUp(): Void
lmetaDown(): Void
lmetaUp(): Void
rmetaDown(): Void
rmetaUp(): Void
unbindEvents(): Void
Private Members
inputActive: Bool
explicitPosInLine: Int
explicitPosLine: Int
lshiftPressed: Bool
rshiftPressed: Bool
lctrlPressed: Bool
rctrlPressed: Bool
lmetaPressed: Bool
rmetaPressed: Bool
invertedSelection: Bool
update event
Name | Type |
---|---|
text |
String |
emitEnter(): Void
enter event
emitEscape(): Void
escape event
selection event
Name | Type |
---|---|
selectionStart |
Int |
selectionEnd |
Int |
emitStop(): Void
stop 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(): Void
Metadata
Name | Parameters |
---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:allow |
ceramic.App |