1.6 KiB
1.6 KiB
Menu
This is the menu class. It provides a horizontal menu bar with selectable items. Menu items are displayed in a single row and can have custom colors and callbacks.
Extends: List
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| separatorColor | color | gray | The color used for separator items in the menu |
Functions
| Method | Returns | Description |
|---|---|---|
| Menu.new | Menu | Creates a new Menu instance |
| Menu:Menu | Menu | Initializes the Menu instance |
| Menu:Menu | Menu | Sets the menu items and calculates total width |
| Menu:Menu | - | Renders the menu horizontally with proper spacing and colors |
| Menu:Menu | boolean | Handles mouse click events and item selection |
Menu.new()
Creates a new Menu instance
Returns
MenuselfThe newly created Menu instance
Menu:Menu(props, basalt)
Parameters
propstableThe properties to initialize the element withbasalttableThe basalt instance
Returns
MenuselfThe initialized instance
Menu:Menu(items)
Sets the menu items
Parameters
itemstable[] List of items with {text, separator, callback, foreground, background} properties
Returns
MenuselfThe Menu instance
Usage
menu:setItems({{text="File"}, {separator=true}, {text="Edit"}})
Menu:Menu()
Menu:Menu(button, x, y)
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanWhetherthe event was handled