Atlas Engine
API Referencegraphite

TextField

Editable text input with focus, cursor, placeholder, and change callbacks.

Module: graphite

Editable text input with focus, cursor, placeholder, and change callbacks.

Declaration

export class TextField extends UIObject { ... }

Extends: UIObject

Constructors

constructor();
constructor(
            font: Font,
            maximumWidth: number,
            position: Position2d,
            text: string,
            placeholder: string,
        );

Properties

text

text: string;

placeholder

placeholder: string;

font

font: Font;

position

position: Position3d;

fontSize

fontSize: number;

padding

padding: Size2d;

maximumWidth

maximumWidth: number;

textColor

textColor: Color;

placeholderColor

placeholderColor: Color;

backgroundColor

backgroundColor: Color;

borderColor

borderColor: Color;

focusedBorderColor

focusedBorderColor: Color;

cursorColor

cursorColor: Color;

Methods

getSize

Returns the current dimensions.

override getSize(): Size2d;

getScreenPosition

Returns the UI element's screen-space position.

override getScreenPosition(): Position2d;

setScreenPosition

Sets the UI element's screen-space position.

override setScreenPosition(position: Position2d): void;

getText

getText(): string;

isFocused

isFocused(): boolean;

getCursorIndex

getCursorIndex(): number;

style

Returns the element's style.

style(): UIStyle;

setText

setText(text: string): TextField;

setPlaceholder

setPlaceholder(placeholder: string): TextField;

setPadding

setPadding(padding: Size2d): TextField;

setMaximumWidth

setMaximumWidth(width: number): TextField;

setFontSize

setFontSize(size: number): TextField;

setStyle

Applies a style to the element.

setStyle(style: UIStyle): TextField;

setOnChange

Registers the text-change callback and returns this text field for chaining.

setOnChange(callback: TextField.ChangeCallback): TextField;

focus

Gives keyboard focus to the text field.

focus(): void;

blur

Removes keyboard focus from the text field.

blur(): void;

On this page