Log inGet started
Package

widget.module

Newest version

This package holds more than this page lists. See all of its files in its world.

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 open state. Right-click sensing on interactive widgets (and self-toggling menus) is future work — for now, drive open yourself in onClick / onCallback handlers.
  • 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.