EditText
Component that enables text editing functionality for Text visuals.
This component provides text input, selection, and editing capabilities when attached to a Text entity. It handles user input, cursor positioning, text selection, and clipboard operations.
Instance Members
entity: Text
The Text entity this component is attached to.
multiline: Bool
Whether multiline editing is enabled. When false, pressing Enter will submit the text. When true, pressing Enter will create a new line.
editing: Bool
Whether this EditText is currently active and editing.
selectionColor: Color
The color used for text selection highlighting.
textCursorColor: Color
The color of the text cursor.
textCursorOffsetX: Float
Horizontal offset for the text cursor position.
textCursorOffsetY: Float
Vertical offset for the text cursor position.
textCursorHeightFactor: Float
Height factor for the text cursor (1.0 = full line height).
textCursorWidth: Float
Width of the text cursor in pixels.
disabled: Bool
Whether text editing is disabled. When disabled, the user cannot edit the text.
container: Visual
Optional container on which pointer events are bound
selectText: SelectText
SelectText instance used internally to manage text selection. Will be defined after component has been assigned to an entity.
initializerName: String
Start text input and editing.
Name | Type | Default | Description |
---|---|---|---|
selectionStart |
Int | -1 |
Initial cursor position or selection start (-1 for end of text) |
selectionEnd |
Int | -1 |
Selection end position (-1 for no selection) |
stopInput(): Void
Stop text input and editing.
Update the text content programmatically while editing.
Name | Type | Description |
---|---|---|
text |
String | The new text content |
focus(): Void
Give focus to this text field and start editing. Selects all text by default.
Find the closest position in a target line from a position in another line. Used for vertical cursor navigation.
Name | Type | Description |
---|---|---|
fromPosition |
Int | Position in the source line |
fromLine |
Int | Source line number |
toLine |
Int | Target line number |
Returns | Description |
---|---|
Int | Closest position in the target line |
textInputNumberOfLines(): Int
Get the total number of lines in the text.
Returns | Description |
---|---|
Int | Number of lines |
Get the global character index from a line number and position within that line.
Name | Type | Description |
---|---|---|
lineNumber |
Int | The line number (0-based) |
lineOffset |
Int | Position within the line |
Returns | Description |
---|---|
Int | Global character index |
Get the line number for a given character index.
Name | Type | Description |
---|---|---|
index |
Int | Global character index |
Returns | Description |
---|---|
Int | Line number (0-based) |
Get the position within a line for a given character index.
Name | Type | Description |
---|---|---|
index |
Int | Global character index |
Returns | Description |
---|---|
Int | Position within the line |
destroy(): Void
new(selectionColor: Color, textCursorColor: Color, ?textCursorOffsetX: Float = 0, ?textCursorOffsetY: Float = 0, ?textCursorHeightFactor: Float = 1, ?textCursorWidth: Float = 1): Void
Create a new EditText component.
Name | Type | Default | Description |
---|---|---|---|
selectionColor |
Color | Color for text selection highlighting | |
textCursorColor |
Color | Color of the text cursor | |
textCursorOffsetX |
Float | 0 |
Horizontal offset for cursor position |
textCursorOffsetY |
Float | 0 |
Vertical offset for cursor position |
textCursorHeightFactor |
Float | 1 |
Height factor for cursor (1.0 = full line height) |
textCursorWidth |
Float | 1 |
Width of the cursor in pixels |
Private Members
boundContainer: Visual
inputActive: Bool
willUpdateSelection: Bool
textCursor: Quad
textCursorToggleVisibilityTime: Float
inputRectX: Float
inputRectY: Float
inputRectW: Float
inputRectH: Float
Event fired when the text content is updated during editing.
Name | Type | Description |
---|---|---|
content |
String | The updated text content |
emitStart(): Void
Event fired when text editing starts.
emitSubmit(): Void
Event fired when the user submits the text (e.g., pressing Enter in single-line mode).
emitStop(): Void
Event fired when text editing stops.
bindAsComponent(): Void
handleStop(): Void
handleEnter(): Void
handleEscape(): Void
Name | Type |
---|---|
text |
String |
Name | Type |
---|---|
selectionStart |
Int |
selectionEnd |
Int |
inverted |
Bool |
Name | Type |
---|---|
selectionStart |
Int |
selectionEnd |
Int |
bindPointerEvents(): Void
Name | Type |
---|---|
info |
TouchInfo |
Name | Type |
---|---|
delta |
Float |
bindKeyBindings(): Void
computeInputRect(): Void
Name | Type |
---|---|
entity |
Entity |
getEntity(): Entity
Returns |
---|
Entity |
Metadata
Name | Parameters |
---|---|
:build |
ceramic.macros.ComponentMacro.build() |
:autoBuild |
ceramic.macros.ComponentMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |