Canvas Toolkit
← Class index

CLineEdit

Widgets · extends CWidget

Implements the line edit widget.

import { CLineEdit } from "canvas-toolkit-lib";

Declared members

readonly textChanged: CSignal<[string]>;

Signal emitted when text changes.

readonly textEdited: CSignal<[string]>;

Signal emitted when the user edits text.

readonly undoAvailable: CSignal<[boolean]>;

Emitted only when undo availability changes.

readonly redoAvailable: CSignal<[boolean]>;

Emitted only when redo availability changes.

readonly returnPressed: CSignal<[]>;

Signal emitted when Enter or Return confirms acceptable input.

readonly editingFinished: CSignal<[]>;

Public editing finished member.

constructor(parent?: CWidget | null);

Creates a new instance.

text(): string;

Provides text behavior.

echoMode(): CEchoMode;

Returns the current text display mode.

setEchoMode(mode: CEchoMode): void;

Changes display only; stored text and undo history are preserved.

displayText(): string;

Returns rendered text; text() always returns the original value.

canCopy(): boolean;

Whether selected text may be exported to either clipboard.

maxLength(): number;

Maximum UTF-16 length; Infinity means unlimited.

setMaxLength(length: number): void;

Limits future input and truncates existing text when necessary. Lowering the limit clears undo/redo so older states cannot exceed it.

horizontalOffset(): number;

Horizontal displacement of the text, in pixels.

setPlaceholderText(text: string): void;
placeholderText(): string;
isClearButtonEnabled(): boolean;

Returns whether the optional clear button is enabled.

setClearButtonEnabled(enabled: boolean): void;

Shows a clear button for nonempty, editable text.

setText(text: string): void;

Sets the text.

setReadOnly(readOnly?: boolean): void;

Sets the read only.

isReadOnly(): boolean;

Returns whether the read only condition is active.

setValidator(validator: CLineEditValidator | null): void;

Sets the validator.

validator(): CLineEditValidator | null;

Returns the current validator.

hasValidationError(): boolean;

Returns whether the editor is marked as containing invalid data.

setValidationError(error?: boolean): void;

Controls the visual validation-error marker.

completer(): CCompleter | null;

Returns the completer associated with this editor.

setCompleter(completer: CCompleter | null): void;

Associates a completer with this editor.

cursor(): CCursorShape;

Provides cursor behavior.

cursorPosition(): number;

Provides cursor position behavior.

setCursorPosition(position: number): void;

Sets the cursor position.

cursorVisible(): boolean;

Provides cursor visible behavior.

insert(text: string): void;

Inserts .

nativeTextState(): {
        text: string;
        start: number;
        end: number;
    } | null;

@internal Supplies the browser input context for the focused editor.

applyNativeTextUpdate(start: number, end: number, text: string): void;

@internal Applies the replacement reported by the browser input context.

selectionStart(): number;

Provides selection start behavior.

selectionEnd(): number;

Provides selection end behavior.

hasSelection(): boolean;

Returns whether this object has selection.

selectedText(): string;

Returns the selected text.

setSelection(anchor: number, position: number): void;

Sets the selection.

selectAll(): void;

Selects the entire text.

clearSelection(): void;

Clears selection.

sizeHint(): CSize;

Returns the preferred size of the widget.

copy(): void;

Provides copy behavior.

cut(): void;

Provides cut behavior.

paste(): void;

Provides paste behavior.

pasteFromSystem(): Promise<void>;

Reads the system clipboard for a user-invoked Paste command.

protected paintEvent(painter: CPainter): void;

Handles the paint event.

protected keyPressEvent(event: CKeyEvent): void;

Handles the key press event.

protected mousePressEvent(event: CMouseEvent): void;

Handles the mouse press event.

protected mouseDoubleClickEvent(event: CMouseEvent): void;
protected mouseMoveEvent(event: CMouseEvent): void;

Handles the mouse move event.

protected mouseReleaseEvent(event: CMouseEvent): void;

Handles the mouse release event.

protected focusInEvent(event: CFocusEvent): void;

Handles the focus in event.

protected focusOutEvent(event: CFocusEvent): void;

Handles the focus out event.

canUndo(): boolean;

Returns whether an edit can be undone.

canRedo(): boolean;

Returns whether an undone edit can be restored.

undo(): void;

Restores the previous text, cursor and selection.

redo(): void;

Reapplies the next edit, including its cursor and selection.

createStandardContextMenu(): CMenu;

Creates a menu using the current editor state. The caller owns the returned menu and must destroy it after use.

protected contextMenuEvent(event: CContextMenuEvent): void;
destroy(): void;

Releases the completion association.