Skip to content

@modoki/engine / index / UIFocusable

Variable: UIFocusable

const UIFocusable: Trait<{ autoFocus: boolean; focusable: boolean; focusOrder: number; focusScope: string; navDown: string; navLeft: string; navRight: string; navUp: string; }>

UIFocusable — marks a UI entity as reachable by directional focus navigation, so a controller/keyboard can traverse and activate UI without a pointer (Part B of the input-and-ui-focus plan). Purely additive: pointer/touch is unchanged, and focus is inert until nav input arrives.

Focus is resolved per active SCOPE (a menu/screen/modal grouping) so it never jumps between an open modal and the screen behind it. Within a scope, directional movement resolves in order: (1) an explicit hand-authored nav link (nav* GUID) if set, else (2) spatial nearest-in-direction using on-screen rects. focusManager owns the state

  • resolution; uiFocusSystem drives it from the Input resource.

All fields are scalar (GUID strings / number / booleans) → serializes cleanly, is editor-authorable, and passes the trait-scalar guard. v1 is OPT-IN: only entities carrying this trait are focusable (auto-focusability for any interactive element is a deliberate follow-up, to avoid changing existing pointer-only games).

Built with Modoki.