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

ui/appkit_mac

lib/ui/appkit_mac.vk

lib/ui/appkit_mac.vk Pure-Veko macOS AppKit 22-widget desktop backend (ui/appkit_mac). - Zero top-level mut globals: all state resides in ob/ObjcRuntime and MacWinInfo - Direct ffi/* builtins (no use [ffi]), operating under allow-caps = [.ui] - Deterministic headless simulation when rt.headless == true

MacWinInfo struct
signature
MacWinInfo = struct { id str, ns_win i64 = ..., content_view i64 = ..., vibrancy_view i64 = ..., width i64 = ..., height i64 = ..., dpi_scale i64 = ... }
signature
mac-ensure-app = fn [mut rt ob/ObjcRuntime]

Ensures NSApplication.sharedApplication is initialized as a regular foreground GUI app.

signature
mac-open-window = fn [mut rt ob/ObjcRuntime, id str, title str, w i64, h i64, props map] MacWinInfo

Opens a native NSWindow (with optional NSVisualEffectView vibrancy backdrop) or returns a deterministic headless descriptor.

signature
mac-close-window = fn [mut rt ob/ObjcRuntime, ns_win i64]

Closes an NSWindow handle.

signature
mac-create-widget = fn [mut rt ob/ObjcRuntime, content_view i64, kind enum, text str, value_s str, value_n i64, flag bool, items block, props map] map

Creates an AppKit view for kind under content_view and returns { view = i64, sub_views = [...] }.

signature
mac-update-widget = fn [mut rt ob/ObjcRuntime, view i64, kind enum, text str, value_s str, value_n i64, flag bool, items block, props map]

Updates an existing AppKit widget view in place without recreating its OS handle.

signature
mac-destroy-widget = fn [mut rt ob/ObjcRuntime, view i64, sub_views block, kind enum]

Detaches and releases widget views from the AppKit view hierarchy.

signature
mac-set-frame = fn [mut rt ob/ObjcRuntime, view i64, win_h i64, x i64, y i64, w i64, h i64]

Positions view inside an AppKit window of height win_h, flipping top-left (x, y) to bottom-left Cocoa coordinates.

signature
mac-set-menu-bar = fn [mut rt ob/ObjcRuntime, menus block] map

Installs an NSMenu application menu bar from menus descriptors and returns a tag -> label map.

signature
mac-focus-view = fn [mut rt ob/ObjcRuntime, ns_win i64, view i64]

Moves keyboard focus to view inside ns_win.

signature
mac-read-text = fn [mut rt ob/ObjcRuntime, view i64, kind enum] str

Reads the current text value from an AppKit widget view.

mac-read-secret fn .secret
signature
mac-read-secret = fn [mut rt ob/ObjcRuntime, view i64] secret str

Reads an NSSecureTextField directly into a .secret str without creating an unflagged plain str.

mac-present-canvas fn caps: .ffi
signature
mac-present-canvas = fn [mut rt ob/ObjcRuntime, view i64, canvas_any any]

Presents an RGBA32 canvas (width, height, pixels) onto view.layer.contents via CGImageCreate.

signature
mac-open-file-dialog = fn [mut rt ob/ObjcRuntime, title str] str
signature
mac-save-file-dialog = fn [mut rt ob/ObjcRuntime, title str] str
signature
mac-pick-folder-dialog = fn [mut rt ob/ObjcRuntime, title str] str
signature
mac-alert-dialog = fn [mut rt ob/ObjcRuntime, title str, body str, kind enum] enum

Displays an NSAlert modal dialog (kind in .info | .warning | .danger | .confirm), returning .ok | .yes | .no | .cancel.

signature
mac-pump-events = fn [mut rt ob/ObjcRuntime, timeout_ms i64]

Pumps pending NSEvent items from NSApplication (waiting up to timeout_ms on the first event).