# BusUiActivated

> Talos next · Since 0.6

Payload of the engine-published `"ui-activated"` event: a node on a screen was activated — a click, a tap, Return or Space on the focused node, the pad's `uiActivate`, or `POST /ui/activate`.

Screens have no handlers, by design: a screen is a function of its props. This is how the game hears a press instead. It is raised before behaviors' `update` on the tick after the press, `by` is null, and unlike `"trigger"` and `"collision"` it reaches {@link Behavior.onEvent} as well as `on`/`once`, because a menu's owner rarely has anything else to listen to. `ts ctx.events.on("ui-activated", (ev) => { if (ev.data.screen === "main-menu" && ev.data.id === "start") ctx.ui.pop() }) ```

## Signature

```ts
export interface BusUiActivated {
  /** The qualified id `GET /ui` reports, with the path of named ancestors: `"main-menu:menu/start"`. */
  node: string
  /** The screen it is on: `"main-menu"`. Null only for an id with no screen prefix. */
  screen: string | null
  /** The author's own id, as the screen wrote it: `"start"`. Match on this and `screen`, not on `node`. */
  id: string
}
```

Import: `import type { BusUiActivated } from "@argus/api"`

## Members

| Member | Signature | Description |
|---|---|---|
| `node` | `node: string` | The qualified id `GET /ui` reports, with the path of named ancestors: `"main-menu:menu/start"`. |
| `screen` | `screen: string \| null` | The screen it is on: `"main-menu"`. Null only for an id with no screen prefix. |
| `id` | `id: string` | The author's own id, as the screen wrote it: `"start"`. Match on this and `screen`, not on `node`. |

## Example

The tested fixture `fixtures/recipes/jump-pad-and-elevator/scenes/behaviors/camera-zone.ts`.

```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>
```
