veko doc
Self-Contained API Reference • Gradual Types • Capabilities • Wasm Sandbox

ui/desktop

lib/ui/desktop.vk

lib/ui/desktop.vk First-class declarative MVU desktop UI framework layered over ui/view and ui/native: - Zero top-level mut globals; all state lives in owned Context / Session values. - Keyed native reconciler preserving OS widget handles & keyboard focus across updates. - Intrinsic-measured Flex / Grid / Form / SplitView / Tabs layout solver (DeferWindowPos). - Hybrid dispatch: supports BOTH pure data/enum actions in update AND inline closure handlers. - Zero-poll async spawn-task bridge waking the native UI event loop over chan + thread wake. - .secret firewall: password-field contents never enter state; read-secret returns secret str.

signature
window = fn [title str, props map, children block[v/Node]] v/Node
signature
menu-bar = fn [children block[v/Node]] v/Node
menu fn
signature
menu = fn [title str, children block[v/Node]] v/Node
signature
menu-item = fn [label str, action any, props map] v/Node
signature
menu-divider = fn [] v/Node
signature
toolbar = fn [props map, children block[v/Node]] v/Node
signature
status-bar = fn [segments block] v/Node
signature
context-menu = fn [id str, items block, action any] v/Node
signature
split-view = fn [props map, first v/Node, second v/Node] v/Node
tabs fn
signature
tabs = fn [id str, active_id str, action any, children block[v/Node]] v/Node
tab fn
signature
tab = fn [id str, label str, children block[v/Node]] v/Node
signature
vstack = fn [props map, children block[v/Node]] v/Node
signature
hstack = fn [props map, children block[v/Node]] v/Node
grid fn
signature
grid = fn [cols i64, gap i64, children block[v/Node]] v/Node
form fn
signature
form = fn [props map, children block[v/Node]] v/Node
signature
scroll = fn [props map, children block[v/Node]] v/Node
signature
group-box = fn [title str, props map, children block[v/Node]] v/Node
card fn
signature
card = fn [title str, props map, children block[v/Node]] v/Node
signature
section = fn [title str, children block[v/Node]] v/Node
row fn
signature
row = fn [props map, children block[v/Node]] v/Node
signature
heading = fn [content str] v/Node
signature
label = fn [content str, props map] v/Node
text fn
signature
text = fn [content str] v/Node
signature
text-styled = fn [content str, props map] v/Node
signature
banner = fn [tone enum, message str, visible bool] v/Node
signature
badge = fn [label str, tone enum] v/Node
stat fn
signature
stat = fn [label str, value str, delta str, tone enum] v/Node
signature
button = fn [label str, action any] v/Node
signature
button-styled = fn [label str, props map, action any] v/Node
signature
text-field = fn [id str, placeholder str, value str, action any] v/Node
signature
text-area = fn [id str, placeholder str, value str, action any] v/Node
signature
password-field = fn [id str, placeholder str] v/Node
signature
checkbox = fn [label str, checked bool, action any] v/Node
signature
toggle-switch = fn [label str, is_on bool, action any] v/Node
signature
radio-group = fn [id str, options block, selected str, action any] v/Node
signature
select = fn [id str, options block, selected str, action any] v/Node
signature
slider = fn [id str, min_v i64, max_v i64, val i64, action any] v/Node
signature
progress = fn [pct i64, label str, tone enum] v/Node
signature
list-box = fn [id str, items block, selected str, action any] v/Node
signature
tree-view = fn [id str, roots block, selected_id str, action any] v/Node
signature
table-view = fn [id str, columns block, rows block, selected_row i64, action any] v/Node
signature
canvas-slot = fn [id str, props map] v/Node
signature
webview = fn [id str, props map] v/Node
signature
native-slot = fn [id str, handle i64, props map] v/Node
signature
divider = fn [] v/Node
signature
spacer = fn [height i64] v/Node
signature
empty = fn [] v/Node
signature
secret-field-badge = fn [label str] v/Node
Event struct
signature
Event = struct { kind enum = ..., action any = ..., widget_id str = ..., text str = ..., value str = ..., value_n i64 = ..., flag bool = ..., w i64 = ..., h i64 = ... }
Context struct
signature
Context = struct { app nat/NativeApp, win_id str = ..., inbox any = ..., running bool = ..., mounted map = ..., actions map = ..., menu_actions map = ..., tray_click_action any = ..., tray_menu_actions map = ..., shortcut_actions map = ..., webview_ipc_actions map = ..., last_rects map = ..., dpi_scale i64 = ..., frame_count i64 = ... }
read-secret fn .secret
signature
read-secret = fn [ctx Context, wid str] secret str

Extracts masked password-field input as a .secret-protected secret str.

signature
focus = fn [ctx Context, wid str]
signature
native-handle = fn [ctx Context, wid str] i64
signature
open-file-dialog = fn [mut ctx Context, title str, filters block] str
signature
save-file-dialog = fn [mut ctx Context, title str, filters block] str
signature
pick-folder-dialog = fn [mut ctx Context, title str] str
signature
alert = fn [mut ctx Context, title str, body str, kind enum] enum
quit fn
signature
quit = fn [mut ctx Context]
signature
enable-remote-webview = fn [mut ctx Context, grant any] any

Unlocks remote (http://, https://, ws://, wss://) navigation in webview widgets. Requires an authentic NetGrant witness produced by ui/webview_net/grant-net (.net capability).

signature
system-tray = fn [mut ctx Context, tooltip str, icon_canvas any, menu_items block, click_action any] bool
signature
update-tray = fn [mut ctx Context, tooltip str, icon_canvas any, menu_items block] bool
signature
remove-tray = fn [mut ctx Context]
signature
notify = fn [mut ctx Context, title str, body str] bool
signature
notify-styled = fn [mut ctx Context, title str, body str, tone enum] bool
signature
register-shortcut = fn [mut ctx Context, chord str, action any] any
signature
unregister-shortcut = fn [mut ctx Context, chord str] bool
signature
eval-js = fn [mut ctx Context, wid str, js str] any
signature
post-webview-message = fn [mut ctx Context, wid str, msg str] any
signature
webview-navigate = fn [mut ctx Context, wid str, url str] any
signature
webview-set-html = fn [mut ctx Context, wid str, html str] any
signature
task-channel = fn [ctx Context] map

Captures the thread-safe result channel & wake handle of ctx so native spawn [...] workers without closure captures can push results back into ctx.inbox via post-task-result.

post-task-result fn caps: .ffi
signature
post-task-result = fn [tch map, action_tag any, val any]

Sends a background task completion message onto tch (task-channel) and wakes the UI thread if live.

spawn-task fn caps: .ffi
signature
spawn-task = fn [ctx Context, action_tag any, work_fn fn[->any]]

Spawns an isolated background worker and pushes { action = action_tag, value = res } directly into ctx.inbox, waking the OS UI loop immediately with zero polling. On Track C --native (where spawn enforces zero closure captures across OS threads), falls back cleanly to executing work_fn and posting { action = action_tag, value = res }.

signature
reconcile-and-layout = fn [mut ctx Context, root v/Node]

Reconciles the native widget tree against root and applies DPI-scaled DeferWindowPos layout.

signature
init-context = fn [title str, props map] Context
signature
init-session = fn [init_state any, view_fn fn[any->v/Node]] Context

Initializes Context from the root window node of view_fn(state).

signature
step-frame = fn [mut st any, mut ctx Context, view_fn fn[any->v/Node], update_fn fn[any,Event,mut Context->any]] any

Executes a single reconcile -> layout -> poll/drain -> dispatch frame deterministically.

run fn
signature
run = fn [init_state any, view_fn fn[any->v/Node], update_fn fn[any,Event,mut Context->any]] any

Runs the native desktop application event loop until closed or desktop/quit is called.