Skip to content

Menu

extends Collection

Menu: horizontal menu bar with optional dropdown submenus and separators.

items entries:

lua
"Save"                                       -- plain item
{ text = "File", items = {"New", "Open"} }   -- item with submenu
{ separator = true }                         -- vertical separator

Fires "select"(index, item) for plain items and "select"(subIndex, subItem, parentIndex) for submenu entries.

Properties

PropertyTypeDefaultDescription
spacingnumber1Gap between menu entries
backgroundnumber|falsecolors.grayBackground color (false = transparent)
separatorColornumbercolors.lightGrayColor of separator entries
dropBackgroundnumbercolors.blackBackground of the expanded list
widthnumberdynamicWidth in terminal cells
heightnumberdynamicHeight in terminal cells

Methods

Selects a top-level item; items with a submenu toggle it open instead.

  • index (integer) The item index

  • emit (boolean, optional) false suppresses the select event

  • returns (self)

Initializes per-instance state and input handlers.

Handles keyboard input while focused.

  • event (string) The key event name (key, key_up, char, paste)
  • a (any) Key code or typed text
  • b (any, optional) Secondary key-event value

Removes all menu entries and closes any open submenu.

  • returns (self)

Intrinsic size for basalt.auto().

  • returns width (number) The measured width
  • returns height (number) The measured height

Renders the element into the buffer.

  • buf (Render) The render buffer (local coordinates, pre-clipped)

Last updated:

Released under the MIT License.