# UiPanelHit

> Talos next · Since next

One pointer ray's hit on a world-space UI panel, as of the last UI frame ({@link UiHandle.panelHits}).

## Signature

```ts
export interface UiPanelHit {
  /** The entity carrying the `uiPanel`. */
  readonly panel: EntityHandle
  /** The ray's source: `"mouse"`, `"hand-left"`, `"hand-right"`, or `"ray-<n>"`. */
  readonly pointer: string
  /** Where it landed, in the panel's pixels from its left (the space its screen lays out in). */
  readonly x: number
  /** And from its top. */
  readonly y: number
  /** Metres from the ray's origin. */
  readonly distance: number
  /** Whether the source's button (the mouse's left button, a hand's trigger) is held. */
  readonly pressed: boolean
}
```

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

## Members

| Member | Signature | Description |
|---|---|---|
| `panel` | `readonly panel: EntityHandle` | The entity carrying the `uiPanel`. |
| `pointer` | `readonly pointer: string` | The ray's source: `"mouse"`, `"hand-left"`, `"hand-right"`, or `"ray-<n>"`. |
| `x` | `readonly x: number` | Where it landed, in the panel's pixels from its left (the space its screen lays out in). |
| `y` | `readonly y: number` | And from its top. |
| `distance` | `readonly distance: number` | Metres from the ray's origin. |
| `pressed` | `readonly pressed: boolean` | Whether the source's button (the mouse's left button, a hand's trigger) is held. |

## Example

The tested fixture `fixtures/app/agent.ts`.

```ts
import type { Behavior } from "@argus/api"

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior
```
