Skip to content

@jsvision/ui / DispatchEvent

Interface: DispatchEvent

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

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:139

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:144

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:129

The wrapped decoded input event or internal command.


focusView?

readonly optional focusView?: (view) => void

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

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:187

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:131

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:162

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:133

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


observeClipboardWrite?

readonly optional observeClipboardWrite?: (listener) => void

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

Observe canonical clipboard writes made during this dispatch.

The subscription lasts only for the current routed event. A pre-processing view can use it to refresh a visible clipboard projection after any focused control calls setClipboard, without becoming another clipboard owner.

Parameters

listener

(text) => void

Returns

void


popupHost?

readonly optional popupHost?: PopupHost

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

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:182

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:156

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:154

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:167

Commit text to the canonical application clipboard and offer it to the host adapter. Host synchronization may be unavailable, but the canonical write still succeeds.

Parameters

text

string

Returns

void