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.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new UIFocusScope(
host,options):UIFocusScope
Defined in: ui/src/focus/UIFocusScope.ts:321
Internal
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”UIFocusScope
Accessors
Section titled “Accessors”_pollsDevice
Section titled “_pollsDevice”Get Signature
Section titled “Get Signature”get _pollsDevice():
boolean
Defined in: ui/src/focus/UIFocusScope.ts:509
Internal
Whether this scope reads a device at all.
Returns
Section titled “Returns”boolean
candidates
Section titled “candidates”Get Signature
Section titled “Get Signature”get candidates(): readonly
UIElement[]
Defined in: ui/src/focus/UIFocusScope.ts:341
Every element focus can reach right now, in tree order.
Returns
Section titled “Returns”readonly UIElement[]
focused
Section titled “focused”Get Signature
Section titled “Get Signature”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.
Returns
Section titled “Returns”UIElement | null
hasInput
Section titled “hasInput”Get Signature
Section titled “Get Signature”get hasInput():
boolean
Defined in: ui/src/focus/UIFocusScope.ts:336
Whether this scope is the one reading input right now.
Returns
Section titled “Returns”boolean
Methods
Section titled “Methods”_clearFocusedOnDestroy()
Section titled “_clearFocusedOnDestroy()”_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.
Parameters
Section titled “Parameters”element
Section titled “element”Returns
Section titled “Returns”void
_containsScope()
Section titled “_containsScope()”_containsScope(
scope):boolean
Defined in: ui/src/focus/UIFocusScope.ts:497
Internal
Whether scope sits inside this one’s subtree.
Parameters
Section titled “Parameters”UIFocusScope
Returns
Section titled “Returns”boolean
_destroy()
Section titled “_destroy()”_destroy():
void
Defined in: ui/src/focus/UIFocusScope.ts:453
Internal
Leave every element and stop reading input.
Returns
Section titled “Returns”void
_isShown()
Section titled “_isShown()”_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.
Returns
Section titled “Returns”boolean
_releaseInput()
Section titled “_releaseInput()”_releaseInput():
void
Defined in: ui/src/focus/UIFocusScope.ts:532
Internal
Stop reading input, keeping the remembered element.
Returns
Section titled “Returns”void
_replaceOptions()
Section titled “_replaceOptions()”_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.
Parameters
Section titled “Parameters”options
Section titled “options”Returns
Section titled “Returns”void
_takeInput()
Section titled “_takeInput()”_takeInput(
input):void
Defined in: ui/src/focus/UIFocusScope.ts:514
Internal
Start reading input: latch held names, light an element.
Parameters
Section titled “Parameters”UIFocusInputSource | null
Returns
Section titled “Returns”void
_tick()
Section titled “_tick()”_tick(
input):void
Defined in: ui/src/focus/UIFocusScope.ts:549
Internal
One frame of this scope: validate, pointer, poll.
Parameters
Section titled “Parameters”UIFocusInputSource | null
Returns
Section titled “Returns”void
activate()
Section titled “activate()”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.
Returns
Section titled “Returns”void
cancel()
Section titled “cancel()”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.
Returns
Section titled “Returns”void
focus()
Section titled “focus()”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.
Parameters
Section titled “Parameters”element
Section titled “element”UIElement | null
Returns
Section titled “Returns”boolean
Throws
Section titled “Throws”when element is not inside this scope.
move()
Section titled “move()”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.
Parameters
Section titled “Parameters”direction
Section titled “direction”Returns
Section titled “Returns”boolean
setOptions()
Section titled “setOptions()”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.
Parameters
Section titled “Parameters”options
Section titled “options”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.