mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(web/menu): send args in callback function
This commit is contained in:
@@ -27,10 +27,11 @@ RegisterNUICallback('confirmSelected', function(data, cb)
|
|||||||
cb(1)
|
cb(1)
|
||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
local selected = data
|
local selected = data
|
||||||
|
local args = registeredMenus[openMenu].options[selected+1].args
|
||||||
if type(selected) == 'number' then
|
if type(selected) == 'number' then
|
||||||
registeredMenus[openMenu].cb(selected)
|
registeredMenus[openMenu].cb(selected, nil, args)
|
||||||
else
|
else
|
||||||
registeredMenus[openMenu].cb(selected[1], selected[2])
|
registeredMenus[openMenu].cb(selected[1], selected[2], args)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -38,10 +39,11 @@ RegisterNUICallback('changeSelected', function(data, cb)
|
|||||||
cb(1)
|
cb(1)
|
||||||
if not registeredMenus[openMenu].onChange then return end
|
if not registeredMenus[openMenu].onChange then return end
|
||||||
local selected = data
|
local selected = data
|
||||||
|
local args = registeredMenus[openMenu].options[selected+1].args
|
||||||
if type(selected) == 'number' then
|
if type(selected) == 'number' then
|
||||||
registeredMenus[openMenu].onChange(selected)
|
registeredMenus[openMenu].onChange(selected, nil, args)
|
||||||
else
|
else
|
||||||
registeredMenus[openMenu].onChange(selected[1], selected[2])
|
registeredMenus[openMenu].onChange(selected[1], selected[2], args)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
@@ -55,15 +57,11 @@ RegisterCommand('testMenu', function()
|
|||||||
lib.registerMenu({
|
lib.registerMenu({
|
||||||
id = 'epic_menu',
|
id = 'epic_menu',
|
||||||
title = 'Nice menu',
|
title = 'Nice menu',
|
||||||
onChange = function(selected, scrollIndex)
|
|
||||||
print(selected, scrollIndex)
|
|
||||||
end,
|
|
||||||
options = {
|
options = {
|
||||||
{label = 'Nice option'},
|
{label = 'Nice option'},
|
||||||
{label = 'Nice header', values = {'Option1', 'option2', 'option3'}, description = 'Tooltip description'}
|
{label = 'Nice header', values = {'Option1', 'option2', 'option3'}, description = 'Tooltip description'}
|
||||||
}
|
}
|
||||||
}, function(selected, scrollIndex)
|
}, function(selected, scrollIndex, args)
|
||||||
print(selected, scrollIndex)
|
|
||||||
lib.registerMenu({
|
lib.registerMenu({
|
||||||
id = 'more_epic_menu',
|
id = 'more_epic_menu',
|
||||||
title = 'Nicer menu',
|
title = 'Nicer menu',
|
||||||
@@ -72,11 +70,13 @@ RegisterCommand('testMenu', function()
|
|||||||
lib.showMenu('epic_menu')
|
lib.showMenu('epic_menu')
|
||||||
end,
|
end,
|
||||||
options = {
|
options = {
|
||||||
{label = 'Extra nice option'},
|
{label = 'Extra nice option', args = 'Hello there'},
|
||||||
{label = 'Giga nice option'},
|
{label = 'Giga nice option'},
|
||||||
{label = 'Omega nice option'},
|
{label = 'Omega nice option'},
|
||||||
}
|
}
|
||||||
}, function() end)
|
}, function(selected, scrollIndex, args)
|
||||||
|
print(selected, scrollIndex, args)
|
||||||
|
end)
|
||||||
lib.showMenu('more_epic_menu')
|
lib.showMenu('more_epic_menu')
|
||||||
end)
|
end)
|
||||||
lib.showMenu('epic_menu')
|
lib.showMenu('epic_menu')
|
||||||
|
|||||||
Reference in New Issue
Block a user