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().
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new FocusState(
element,props,behavior):FocusState
Defined in: ui/src/focus/FocusState.ts:76
Parameters
Section titled “Parameters”element
Section titled “element”behavior
Section titled “behavior”Returns
Section titled “Returns”FocusState
Properties
Section titled “Properties”behavior
Section titled “behavior”
readonlybehavior:FocusBehavior
Defined in: ui/src/focus/FocusState.ts:65
Internal
The element’s own hooks, which a scope drives it through.
Accessors
Section titled “Accessors”disabled
Section titled “disabled”Get Signature
Section titled “Get Signature”get disabled():
boolean
Defined in: ui/src/focus/FocusState.ts:108
Internal
Whether the element refuses focus and activation right now.
Returns
Section titled “Returns”boolean
focusable
Section titled “focusable”Get Signature
Section titled “Get Signature”get focusable():
boolean
Defined in: ui/src/focus/FocusState.ts:88
Whether the element takes part in focus navigation.
Returns
Section titled “Returns”boolean
focused
Section titled “focused”Get Signature
Section titled “Get Signature”get focused():
boolean
Defined in: ui/src/focus/FocusState.ts:93
Whether the element holds focus in the scope that owns it.
Returns
Section titled “Returns”boolean
Get Signature
Section titled “Get Signature”get id():
string|undefined
Defined in: ui/src/focus/FocusState.ts:98
The name a sibling’s focusNeighbors points at.
Returns
Section titled “Returns”string | undefined
neighbors
Section titled “neighbors”Get Signature
Section titled “Get Signature”get neighbors():
FocusNeighbors|undefined
Defined in: ui/src/focus/FocusState.ts:103
Per-direction overrides of the position rule.
Returns
Section titled “Returns”FocusNeighbors | undefined
Methods
Section titled “Methods”_adjust()
Section titled “_adjust()”_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.
Parameters
Section titled “Parameters”direction
Section titled “direction”Returns
Section titled “Returns”boolean
_setFocused()
Section titled “_setFocused()”_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.
Parameters
Section titled “Parameters”focused
Section titled “focused”boolean
Returns
Section titled “Returns”void
_setScope()
Section titled “_setScope()”_setScope(
scope):void
Defined in: ui/src/focus/FocusState.ts:161
Internal
Remember the scope holding this element.
Parameters
Section titled “Parameters”UIFocusScope | null
Returns
Section titled “Returns”void
destroy()
Section titled “destroy()”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.
Returns
Section titled “Returns”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.
Parameters
Section titled “Parameters”Returns
Section titled “Returns”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.