Skip to content

@jsvision/ui / DispatchEvent

Interface: DispatchEvent

Defined in: ui/src/view/types.ts:118

The envelope wrapped around each event before it is routed to views. This — not the raw read-only input event — is what View.onEvent(ev) receives. A handler reads the event and sets handled to consume it, and uses the optional seams below (emit, focusView, capture, clipboard, …) to act on the app. Those seams are present during real dispatch and undefined in a bare envelope you might construct in a test, so always call them optional-chained (ev.emit?.(…)).

Properties

clickCount?

readonly optional clickCount?: number

Defined in: ui/src/view/types.ts:130

For a mouse-down, how many consecutive clicks landed on the same cell (1 = single, 2 = double, 3 = triple…). Present only on a mouse-down during real dispatch; undefined otherwise. A row widget that activates on double-click checks ev.clickCount === 2.


emit?

readonly optional emit?: (command, arg?) => void

Defined in: ui/src/view/types.ts:135

Raise a typed command onto the current dispatch tick — how a widget signals an action (e.g. a button emitting 'ok') for a menu/status/app handler to pick up.

Parameters

command

string

arg?

unknown

Returns

void


event

readonly event: AppEvent

Defined in: ui/src/view/types.ts:120

The wrapped decoded input event or internal command.


focusView?

readonly optional focusView?: (view) => void

Defined in: ui/src/view/types.ts:140

Move focus to another view — used e.g. by a Label to focus the control it labels. A non-focusable target is a no-op.

Parameters

view

View

Returns

void


getFocused?

readonly optional getFocused?: () => View | null

Defined in: ui/src/view/types.ts:170

The currently-focused view. A dropdown control saves it before opening its popup and restores it on dismiss.

Returns

View | null


handled

handled: boolean

Defined in: ui/src/view/types.ts:122

Set true by a handler to stop the event propagating to the remaining phases/views.


hasCapture?

readonly optional hasCapture?: (view) => boolean

Defined in: ui/src/view/types.ts:153

Whether view currently holds the pointer capture. A view mid-gesture (a window drag, a status press) checks this before applying a move, so if the capture was lost externally (a modal opened or closed mid-drag) the gesture aborts cleanly instead of jumping to the cursor.

Parameters

view

View

Returns

boolean


local?

readonly optional local?: Point

Defined in: ui/src/view/types.ts:124

Mouse/wheel coordinates translated to this view's local cells; absent for keys and commands.


popupHost?

readonly optional popupHost?: PopupHost

Defined in: ui/src/view/types.ts:175

The overlay host a dropdown control mounts its anchored popup into. Present when an app shell (or a Dialog) has provided one; undefined in a headless/no-shell setup.


readClipboard?

readonly optional readClipboard?: () => string

Defined in: ui/src/view/types.ts:165

Read the application's in-app clipboard buffer (the last text copied or cut within the app). Used by editable controls for in-app paste without reading the external OS clipboard. Returns '' when nothing has been copied yet, and is undefined on an event that was not routed through the loop (e.g. one constructed directly in a test) — always call it optional-chained.

Returns

string


releaseCapture?

readonly optional releaseCapture?: () => void

Defined in: ui/src/view/types.ts:147

Release the pointer capture; a no-op if none is set. Pairs with setCapture.

Returns

void


setCapture?

readonly optional setCapture?: (view) => void

Defined in: ui/src/view/types.ts:145

Capture the pointer to view: while captured, all mouse/wheel events route to view until releaseCapture. Used for drag gestures such as dragging a scrollbar thumb.

Parameters

view

View

Returns

void


setClipboard?

readonly optional setClipboard?: (text) => void

Defined in: ui/src/view/types.ts:158

Write text to the system clipboard — used by Input copy/cut. A no-op when the terminal has no clipboard support; the control never touches I/O directly.

Parameters

text

string

Returns

void