Skip to content

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

PropertyTypeDefaultDescription
separatorColorcolorgrayThe color used for separator items in the menu
spacingnumber0The number of spaces between menu items
openDropdowntablenilCurrently open dropdown data
dropdownBackgroundcolorblackBackground color for dropdown menus
dropdownForegroundcolorwhiteForeground color for dropdown menus
horizontalOffsetnumber0Current horizontal scroll offset
maxWidthnumbernilMaximum width before scrolling is enabled (nil = auto-size to items)

Functions

MethodReturnsDescription
Menu:getTotalWidthnumberCalculates total width of menu items
Menu:showDropdown-Shows dropdown menu
Menu:hideDropdown-Closes dropdown menu
Menu:isInsideDropdownbooleanChecks if position is in dropdown
Menu:handleDropdownClickbooleanHandles dropdown click

Calculates the total width of all menu items with spacing

Returns

  • number totalWidth The total width of all items

Shows a dropdown menu for a specific item

Parameters

  • index number The item index
  • item table The menu item
  • itemX number The X position of the item

Closes the currently open dropdown

Checks if a position is inside the dropdown

Parameters

  • relX number Relative X position
  • relY number Relative Y position
  • dropdown table Dropdown data

Returns

  • boolean inside Whether position is inside dropdown

Handles click inside dropdown

Parameters

  • relX number Relative X position
  • relY number Relative Y position
  • dropdown table Dropdown data

Returns

  • boolean handled Whether click was handled

Released under the MIT License.