Skip to content

UIFocusScope

Defined in: ui/src/focus/UIFocusScope.ts:264

Keyboard and gamepad focus over one subtree.

A game reaches its scope through surface.focusScope, panel.focusScope or root.focusScope and never builds one. Every method works with no engine attached, so a cutscene script or a unit test can drive it.

The scope reading input owns the pointer too: everything drawn under it stops answering the mouse, so a dialog cannot be clicked through. modal: false leaves the pointer to whatever is behind.

new UIFocusScope(host, options): UIFocusScope

Defined in: ui/src/focus/UIFocusScope.ts:321

Internal

UIFocusScopeHost

UIFocusScopeOptions

UIFocusScope

get _pollsDevice(): boolean

Defined in: ui/src/focus/UIFocusScope.ts:509

Internal

Whether this scope reads a device at all.

boolean


get candidates(): readonly UIElement[]

Defined in: ui/src/focus/UIFocusScope.ts:341

Every element focus can reach right now, in tree order.

readonly UIElement[]


get focused(): UIElement | null

Defined in: ui/src/focus/UIFocusScope.ts:331

The element this scope remembers. It is painted and acted on only while hasInput is true.

UIElement | null


get hasInput(): boolean

Defined in: ui/src/focus/UIFocusScope.ts:336

Whether this scope is the one reading input right now.

boolean

_clearFocusedOnDestroy(element): void

Defined in: ui/src/focus/UIFocusScope.ts:475

Internal

Drop a focused element that is being torn down, with no callback and no repaint: painting here reaches a freed Yoga node. The tree index is kept so the next validation lands beside it.

UIElement

void


_containsScope(scope): boolean

Defined in: ui/src/focus/UIFocusScope.ts:497

Internal

Whether scope sits inside this one’s subtree.

UIFocusScope

boolean


_destroy(): void

Defined in: ui/src/focus/UIFocusScope.ts:453

Internal

Leave every element and stop reading input.

void


_isShown(): boolean

Defined in: ui/src/focus/UIFocusScope.ts:487

Internal

Whether this scope’s host and all its ancestors are visible. Hiding a surface, disabling its component and deactivating its entity all write that flag.

boolean


_releaseInput(): void

Defined in: ui/src/focus/UIFocusScope.ts:532

Internal

Stop reading input, keeping the remembered element.

void


_replaceOptions(options): void

Defined in: ui/src/focus/UIFocusScope.ts:448

Internal

Take options as the whole declaration: a key left out goes back to its default, so a callback a React render stopped passing is dropped.

UIFocusScopeOptions

void


_takeInput(input): void

Defined in: ui/src/focus/UIFocusScope.ts:514

Internal

Start reading input: latch held names, light an element.

UIFocusInputSource | null

void


_tick(input): void

Defined in: ui/src/focus/UIFocusScope.ts:549

Internal

One frame of this scope: validate, pointer, poll.

UIFocusInputSource | null

void


activate(): void

Defined in: ui/src/focus/UIFocusScope.ts:409

Run the focused element’s own action (the one a click runs), then onActivate. A disabled or unfocused scope does nothing. While an element under this scope holds its input, this confirms that element. Paints no pressed look; that belongs to a held confirm action.

void


cancel(): void

Defined in: ui/src/focus/UIFocusScope.ts:423

Run onCancel. While an element under this scope holds its input, this cancels that element and onCancel does not run.

void


focus(element): boolean

Defined in: ui/src/focus/UIFocusScope.ts:357

Move focus to one element of this scope, reporting whether it landed. null clears focus. A hidden, disabled or non-focusable element returns false with a development warning.

UIElement | null

boolean

when element is not inside this scope.


move(direction): boolean

Defined in: ui/src/focus/UIFocusScope.ts:392

Move focus one step, reporting whether the press did anything: focus changed, or the focused element consumed the step as an adjustment.

While an element under this scope holds its input, the step goes to that element, focus stays, and the result is true.

FocusDirection

boolean


setOptions(options): void

Defined in: ui/src/focus/UIFocusScope.ts:439

Replace the options this scope was built with, key by key. A key the caller left out keeps its value.

UIFocusScopeOptions

void

Coding agents: fetch https://yage.dev/llms.txt first and prefer the Markdown references it links over these HTML pages. This page's Markdown counterpart is /llms/packages/ui.md.