Menu
Keyboard-navigable list menus with side-scroll values, checkboxes, and icons.
Client Exports
registerMenu
Register a menu with a change handler callback.
exports['trinity-ui']:registerMenu(data, cb)Menu Properties:
| Property | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Unique menu identifier |
title | string | Yes | Menu title |
options | table[] | Yes | Array of menu items |
position | string | — | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' |
disableInput | boolean | — | Disable player movement while open |
canClose | boolean | — | Whether the menu can be closed (default true) |
onClose | function(keyPressed) | — | Called when menu closes |
onSelected | function(selected, scrollIndex, args) | — | Called on item selection |
onSideScroll | function(selected, scrollIndex, args) | — | Called on side-scroll value change |
onCheck | function(selected, checked, args) | — | Called on checkbox toggle |
cb — Legacy callback: function(selected, scrollIndex, args, checked)
Option Properties:
| Property | Type | Description |
|---|---|---|
label | string | Item text (required) |
icon | string | Iconify icon name |
iconColor | string | Icon color (hex) |
description | string | Secondary text |
progress | number | Progress bar (0-100) |
colorScheme | string | Color scheme for the item |
values | table | Side-scroll options (e.g. {'Low', 'Medium', 'High'}) |
defaultIndex | number | Default side-scroll index |
checked | boolean | Show checkbox (initial state) |
args | table | Custom data passed to callbacks |
close | boolean | Close menu on select (default true) |
showMenu
Open a registered menu.
exports['trinity-ui']:showMenu(id, startIndex)| Parameter | Type | Description |
|---|---|---|
id | string | Menu ID |
startIndex | number | Optional starting selection index |
hideMenu
Close the currently open menu.
exports['trinity-ui']:hideMenu()setMenuOptions
Update the options of a registered menu.
exports['trinity-ui']:setMenuOptions(id, options, index)| Parameter | Type | Description |
|---|---|---|
id | string | Menu ID |
options | table | table[] | New option(s) |
index | number | If provided, replaces a single option at this index |
getOpenMenu
Returns the ID of the currently open menu, or nil.
local id = exports['trinity-ui']:getOpenMenu()Example
exports['trinity-ui']:registerMenu({
id = 'vehicle_settings',
title = 'Vehicle Settings',
position = 'top-left',
options = {
{
label = 'Engine',
icon = 'fa6-solid:gear',
description = 'Toggle engine on/off',
},
{
label = 'Window Tint',
icon = 'fa6-solid:car-side',
values = { 'None', 'Light', 'Medium', 'Dark', 'Limo' },
defaultIndex = 1,
description = 'Scroll left/right to change'
},
{
label = 'Neon Lights',
icon = 'fa6-solid:lightbulb',
checked = false,
description = 'Toggle neon underglow'
}
},
onSelected = function(selected, scrollIndex, args)
if selected == 1 then
print('Engine toggled')
end
end,
onSideScroll = function(selected, scrollIndex, args)
print('Tint changed to index: ' .. scrollIndex)
end,
onCheck = function(selected, checked, args)
print('Neon lights: ' .. tostring(checked))
end
})
exports['trinity-ui']:showMenu('vehicle_settings')While a menu is open, weapon firing and the weapon wheel are automatically disabled.
Last updated on