Skip to content

API Interface UIViewElement

github-actions[bot] edited this page Nov 29, 2026 · 4 revisions

Interface: UIViewElement

Defined in: src/engine/ui/host/hostElement.ts:87

A hosted UI element: a node with one UI component, styled by the cascade.

Properties

source

readonly source: UIHostSource | null;

Defined in: src/engine/ui/host/hostElement.ts:140

Where it was written, when the renderer knows (dev builds).


synthetic

readonly synthetic: boolean;

Defined in: src/engine/ui/host/hostElement.ts:142

Made by the renderer, not written: a button's label from its text.


tag

readonly tag: string;

Defined in: src/engine/ui/host/hostElement.ts:136

The tag as written (div, button), which selectors match.


tree

readonly tree: UIHostTree;

Defined in: src/engine/ui/host/hostElement.ts:134


uiTag

readonly uiTag: UITag;

Defined in: src/engine/ui/host/hostElement.ts:138

The UI element it is.

Accessors

attributes

Get Signature

get attributes(): ReadonlyMap<string, string>;

Defined in: src/engine/ui/host/hostElement.ts:170

Its attributes as last set (inline style included).

Returns

ReadonlyMap<string, string>


children

Get Signature

get children(): readonly UIHostElement[];

Defined in: src/engine/ui/host/hostElement.ts:157

Returns

readonly UIHostElement[]


classes

Get Signature

get classes(): readonly string[];

Defined in: src/engine/ui/host/hostElement.ts:165

Returns

readonly string[]


clientHeight

Get Signature

get clientHeight(): number;

Defined in: src/engine/ui/host/hostElement.ts:375

Returns

number


clientWidth

Get Signature

get clientWidth(): number;

Defined in: src/engine/ui/host/hostElement.ts:371

Returns

number


component

Get Signature

get component(): UIComponentType;

Defined in: src/engine/ui/host/hostElement.ts:149

Returns

UIComponentType


id

Get Signature

get id(): string | null;

Defined in: src/engine/ui/host/hostElement.ts:161

Returns

string | null


isValid

Get Signature

get isValid(): boolean;

Defined in: src/engine/ui/host/hostElement.ts:174

Returns

boolean


node

Get Signature

get node(): GameObject;

Defined in: src/engine/ui/host/hostElement.ts:145

Returns

GameObject


parent

Get Signature

get parent(): UIHostElement | null;

Defined in: src/engine/ui/host/hostElement.ts:153

Returns

UIHostElement | null


scrollHeight

Get Signature

get scrollHeight(): number;

Defined in: src/engine/ui/host/hostElement.ts:367

Returns

number


scrollLeft

Get Signature

get scrollLeft(): number;

Defined in: src/engine/ui/host/hostElement.ts:354

Returns

number

Set Signature

set scrollLeft(value): void;

Defined in: src/engine/ui/host/hostElement.ts:358

Parameters
value

number

Returns

void


scrollTop

Get Signature

get scrollTop(): number;

Defined in: src/engine/ui/host/hostElement.ts:346

How far its content is scrolled down and right, in UI pixels (scrollY, scrollX); set them to scroll.

Returns

number

Set Signature

set scrollTop(value): void;

Defined in: src/engine/ui/host/hostElement.ts:350

Parameters
value

number

Returns

void


scrollWidth

Get Signature

get scrollWidth(): number;

Defined in: src/engine/ui/host/hostElement.ts:363

Its content's extent and its padding box, from the last layout (UI pixels).

Returns

number


value

Get Signature

get value(): string | null;

Defined in: src/engine/ui/host/hostElement.ts:195

Input fields: their text (ADR 0428: any control's value as text, as the DOM's value); null for other elements. Setting it isn't a player change (no events).

Returns

string | null

Set Signature

set value(value): void;

Defined in: src/engine/ui/host/hostElement.ts:199

Parameters
value

string

Returns

void

Methods

animate()

animate(
   keyframes, 
   duration, 
   hooks
): UIPlayback;

Defined in: src/engine/ui/host/hostElement.ts:274

Play keyframes on it (ADR 0423: a Svelte transition's or animate:'s, through the renderer's animate hook) on the UI animator (ADR 0422 wave 4: the tween backend, on unscaled time): each keyframe is CSS declarations by property (camel or kebab case), evenly spaced over duration seconds, and the last one's values stay until stop(). Values convert as a stylesheet's do (its variables included); a declaration it can't animate is warned about once and left out. hooks.onFrame runs each frame it plays, hooks.onEnd once at its end.

Parameters

keyframes

readonly Readonly<Record<string, string>>[]

duration

number

hooks

UIPlayHooks

Returns

UIPlayback


as()

as<T>(type): T;

Defined in: src/engine/ui/host/hostElement.ts:179

Its component as type; throws if it's another kind.

Type Parameters

T

T extends UIComponentType

Parameters

type

new (...args) => T

Returns

T


blur()

blur(): void;

Defined in: src/engine/ui/host/hostElement.ts:228

Take its focus away (blur and focusout at once, as the DOM's blur()).

Returns

void


bounds()

bounds(): 
  | {
  height: number;
  width: number;
  x: number;
  y: number;
}
  | null;

Defined in: src/engine/ui/host/hostElement.ts:250

Where it's drawn, in its canvas's UI pixels: its laid-out box through its own and its ancestors' transforms (ADR 0422 wave 3), as the axis-aligned rectangle around it, not cut down by clips (as the DOM's getBoundingClientRect). Its box when nothing transforms it; null when it isn't laid out.

Returns

| { height: number; width: number; x: number; y: number; } | null


click()

click(): void;

Defined in: src/engine/ui/host/hostElement.ts:208

The DOM's click(): a bubbling click dispatched now with HTML's activation (a checkbox toggles before its handlers and back if one prevents it, a submit button submits its form), whose input, change or submit follow at once. Nothing on a control that isn't interactable.

Returns

void


computedStyle()

computedStyle(): Record<string, string>;

Defined in: src/engine/ui/host/hostElement.ts:263

Its values as CSS text by camel-case property, as the DOM's getComputedStyle gives them (ADR 0423: what Svelte's transitions and animate: read through the renderer's measure hook): sizes, edges, transforms and origins in px from the last layout (layoutNow first for an up-to-date one), the transform as translate() rotate() scale() (none when it has none), colours as rgba(). Properties UI elements don't have read as their CSS initial value.

Returns

Record<string, string>


dispatch()

dispatch(event): void;

Defined in: src/engine/ui/host/hostElement.ts:339

Dispatch event (whose element is this element) now through this element's ancestors in the tree, in capture, target and bubble phases (ADR 0426); one that bubbles out of the canvas unstopped goes on to onUIHostBubbleOut.

Parameters

event

UIViewEvent

Returns

void


focus()

focus(): void;

Defined in: src/engine/ui/host/hostElement.ts:216

Give it focus (buttons, input fields and ADR 0428's controls; an input field starts typing, as a click does). As the DOM's focus(), the element that had focus gets blur and focusout, then this one focus and focusin, at once.

Returns

void


off()

off(
   type, 
   listener, 
   options?
): void;

Defined in: src/engine/ui/host/hostElement.ts:331

Parameters

type

UIHostEventType

listener

UIHostListener

options?

| boolean | { capture?: boolean; }

Returns

void


on()

on(
   type, 
   listener, 
   options?
): void;

Defined in: src/engine/ui/host/hostElement.ts:324

Listen to a UI event (click, input, change, submit, focus, blur, pointerenter, pointerleave, and ADR 0426's pointer, key, focus and drag events, ADR 0427's scroll/scrollend), or to stylesheet animation (ADR 0422 wave 4: transitionend, animationstart, animationiteration, animationend, the frame after they happened). capture hears it on the way down to its target; once removes the listener once it ran.

Parameters

type

UIHostEventType

listener

UIHostListener

options?

| boolean | { capture?: boolean; once?: boolean; }

Returns

void


query()

query(selector): UIHostElement | null;

Defined in: src/engine/ui/host/hostElement.ts:185

The first element inside this one a selector matches, or null.

Parameters

selector

string

Returns

UIHostElement | null


queryAll()

queryAll(selector): UIHostElement[];

Defined in: src/engine/ui/host/hostElement.ts:190

Every element inside this one a selector matches, in tree order.

Parameters

selector

string

Returns

UIHostElement[]


rect()

rect(): 
  | {
  height: number;
  width: number;
  x: number;
  y: number;
}
  | null;

Defined in: src/engine/ui/host/hostElement.ts:236

Its box in its canvas's UI pixels from the UI core's last layout, or null when it isn't laid out (a headless World).

Returns

| { height: number; width: number; x: number; y: number; } | null


scrollBy()

scrollBy(...args): void;

Defined in: src/engine/ui/host/hostElement.ts:385

Scroll its content by dx, dy (or { left, top, behavior }).

Parameters

args

...UIScrollToArgs

Returns

void


scrollIntoView()

scrollIntoView(options?): void;

Defined in: src/engine/ui/host/hostElement.ts:390

Scroll its scrolling ancestors so it shows (block, inline: start, center, end, nearest).

Parameters

options?

boolean | UIScrollIntoViewOptions

Returns

void


scrollTo()

scrollTo(...args): void;

Defined in: src/engine/ui/host/hostElement.ts:380

Scroll its content to x, y (or { left, top, behavior }).

Parameters

args

...UIScrollToArgs

Returns

void


toString()

toString(): string;

Defined in: src/engine/ui/host/hostElement.ts:394

Returns

string

Clone this wiki locally