@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?
readonlyoptionalclickCount?: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?
readonlyoptionalemit?: (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
readonlyevent:AppEvent
Defined in: ui/src/view/types.ts:120
The wrapped decoded input event or internal command.
focusView?
readonlyoptionalfocusView?: (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
Returns
void
getFocused?
readonlyoptionalgetFocused?: () =>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?
readonlyoptionalhasCapture?: (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
Returns
boolean
local?
readonlyoptionallocal?: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?
readonlyoptionalpopupHost?: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?
readonlyoptionalreadClipboard?: () =>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?
readonlyoptionalreleaseCapture?: () =>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?
readonlyoptionalsetCapture?: (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
Returns
void
setClipboard?
readonlyoptionalsetClipboard?: (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