2.2 KiB
2.2 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 |
| spacing | number | 0 | The number of spaces between menu items |
| openDropdown | table | nil | Currently open dropdown data {index, items, x, y, width, height} |
| dropdownBackground | color | black | Background color for dropdown menus |
| dropdownForeground | color | white | Foreground color for dropdown menus |
| horizontalOffset | number | 0 | Current horizontal scroll offset |
| maxWidth | number | nil | Maximum width before scrolling is enabled (nil = auto-size to items) |
Functions
| Method | Returns | Description |
|---|---|---|
| Menu:getTotalWidth | number | Calculates total width of menu items |
| Menu:showDropdown | - | Shows dropdown menu |
| Menu:hideDropdown | - | Closes dropdown menu |
| Menu:isInsideDropdown | boolean | Checks if position is in dropdown |
| Menu:handleDropdownClick | boolean | Handles dropdown click |
Menu:getTotalWidth()
Calculates the total width of all menu items with spacing
Returns
numbertotalWidthThe total width of all items
Menu:showDropdown(index, item, itemX)
Shows a dropdown menu for a specific item
Parameters
indexnumberThe item indexitemtableThe menu itemitemXnumberThe X position of the item
Menu:hideDropdown()
Closes the currently open dropdown
Menu:isInsideDropdown(relX, relY, dropdown)
Checks if a position is inside the dropdown
Parameters
relXnumberRelative X positionrelYnumberRelative Y positiondropdowntableDropdown data
Returns
booleaninsideWhether position is inside dropdown
Menu:handleDropdownClick(relX, relY, dropdown)
Handles click inside dropdown
Parameters
relXnumberRelative X positionrelYnumberRelative Y positiondropdowntableDropdown data
Returns
booleanhandledWhether click was handled