Builtin Library
README.md
contextMenu
Convenience wrapper over Z.popup for the context-menu pattern — a
popup pinned to a widget you typically open on right-click. Same
ordering constraint as Z.popup: the anchor must render before the
menu in tree order.
Exports
contextMenu(anchorId: string?, items: { any }?, opts: ContextMenuOpts?) -> WidgetNode— build a context-menu popup attached to the anchor widget.
Types:
ContextMenuOpts = { id?, open?, onDismiss?, pivot?, focusable?, style? }
Usage
local contextMenu = require("@builtin::modules.zui.widget.contextMenu")
-- in your Z.app builder:
Z.btn("Item", "row1"), -- anchor
Z.contextMenu("row1", {
Z.btn("Cut", "ctx:cut"),
Z.btn("Copy", "ctx:copy"),
Z.btn("Paste", "ctx:paste"),
}, { open = menuOpen, onDismiss = "ctx:dismiss" })
Notes
- Wave 3 ships caller-managed
openstate. Right-click sensing on interactive widgets (and self-toggling menus) is future work — for now, driveopenyourself inonClick/onCallbackhandlers. - Default pivot is
"belowLeft". - The wrapper is a thin pass-through; any popup-supported field can be reached by adding it to the surrounding popup directly if needed.