BusUiFocused
Payload of the engine-published "ui-focused" event: focus moved on a screen — the arrow keys or the pad, Tab, a click on a focusable node, or the first focus a screen takes when it comes up.
Once per move, never for a frame where focus stayed put. Raised with "ui-activated" (same tick, same rules, by null), so it reaches {@link Behavior.onEvent} too. What a menu turns into a hover sound, a description panel or a preview, without polling: ts ctx.events.on("ui-focused", (ev) => { if (ev.data.screen === "garage" && ev.data.id) ctx.ui.set("blurb", "text-key", `kart.${ev.data.id}`) }) {@link Ui.focused} answers the same question at any moment.
Signature
export interface BusUiFocused {
/** The qualified id `GET /ui` reports: `"garage:karts/swift"`. Null when focus left every node of the screen. */
node: string | null
/** The screen focus moved on: `"garage"`. */
screen: string
/** The author's own id: `"swift"`. Null with `node`. Match on this and `screen`. */
id: string | null
}
Import: import type { BusUiFocused } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
node | node: string | null | The qualified id GET /ui reports: "garage:karts/swift". Null when focus left every node of the screen. |
screen | screen: string | The screen focus moved on: "garage". |
id | id: string | null | The author's own id: "swift". Null with node. Match on this and screen. |
Example
The tested fixture fixtures/recipes/jump-pad-and-elevator/scenes/behaviors/camera-zone.ts.
import type { Behavior } from "@argus/api"
/**
* A trigger volume that retunes the camera while the player is inside it.
*
* The engine has no camera-zone concept and needs none: a volume, a `trigger` component and this.
* Here the player's behaviour owns the camera (it re-sends its params when the view is turned), so
* the zone tells it what to change rather than calling `ctx.camera.set` itself. In a scene where
* nothing else writes the camera, the zone can call `ctx.camera.set(kind, params)` directly.
*/
interface Props {
/** `ctx.camera.set` params to merge in on the way in, and on the way out. */
inside?: Record<string, unknown>
outside?: Record<string, unknown>
}
export default {
onTrigger(ctx, trigger) {
const params = trigger.entering ? ctx.props.inside : ctx.props.outside
if (params) ctx.events.emit("camera-zone", { target: trigger.other.id, params })
},
} satisfies Behavior<Record<string, never>, Props>