Skip to content

FocusState

Defined in: ui/src/focus/FocusState.ts:63

The focus state of one element: what a scope reads to decide whether the element is a candidate, and where the element’s own focus callbacks live.

Built by the element itself, one per element. The element calls FocusState.destroy from its own destroy().

new FocusState(element, props, behavior): FocusState

Defined in: ui/src/focus/FocusState.ts:76

UIElement

FocusProps

FocusBehavior

FocusState

readonly behavior: FocusBehavior

Defined in: ui/src/focus/FocusState.ts:65

Internal

The element’s own hooks, which a scope drives it through.

get disabled(): boolean

Defined in: ui/src/focus/FocusState.ts:108

Internal

Whether the element refuses focus and activation right now.

boolean


get focusable(): boolean

Defined in: ui/src/focus/FocusState.ts:88

Whether the element takes part in focus navigation.

boolean


get focused(): boolean

Defined in: ui/src/focus/FocusState.ts:93

Whether the element holds focus in the scope that owns it.

boolean


get id(): string | undefined

Defined in: ui/src/focus/FocusState.ts:98

The name a sibling’s focusNeighbors points at.

string | undefined


get neighbors(): FocusNeighbors | undefined

Defined in: ui/src/focus/FocusState.ts:103

Per-direction overrides of the position rule.

FocusNeighbors | undefined

_adjust(direction): boolean

Defined in: ui/src/focus/FocusState.ts:148

Internal

Step along direction, reporting whether the press was consumed and so must not move focus. The game’s onAdjust owns left and right when set; the element’s own stepper owns everything else. The two never both run.

FocusDirection

boolean


_setFocused(focused): void

Defined in: ui/src/focus/FocusState.ts:130

Internal

Record that focus arrived or left, paint it, then tell the game, so a throwing callback cannot leave the flag and the paint apart.

boolean

void


_setScope(scope): void

Defined in: ui/src/focus/FocusState.ts:161

Internal

Remember the scope holding this element.

UIFocusScope | null

void


destroy(): void

Defined in: ui/src/focus/FocusState.ts:170

Leave focus navigation, from the element’s own destroy(). The owning scope drops the element with no callback and no repaint, and a pending pointer request from this element is dropped too.

void


set(props): void

Defined in: ui/src/focus/FocusState.ts:117

Swap focus props in place, from the element’s update(). A present key reassigns, including the explicit undefined the React reconciler emits for a removed prop. An absent key leaves the field alone.

FocusProps

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.