feat(client/radial): return currentMenu and itemIndex onSelect

This commit is contained in:
Linden
2023-02-26 01:59:01 +11:00
parent 60e3a12033
commit 29022e1a48
2 changed files with 12 additions and 4 deletions

View File

@@ -4,7 +4,7 @@ type RadialItem = {
id: string; id: string;
label: string; label: string;
icon: IconName | [IconPrefix, IconName]; icon: IconName | [IconPrefix, IconName];
onSelect?: () => void; onSelect?: (currentMenu: string | null, itemIndex: number) => void;
menu?: string; menu?: string;
}; };

View File

@@ -3,7 +3,7 @@
---@field icon string ---@field icon string
---@field label string ---@field label string
---@field menu? string ---@field menu? string
---@field onSelect? function ---@field onSelect? fun(currentMenu: string | nil, itemIndex: number)
---@field [string] any ---@field [string] any
---@class RadialMenuProps ---@class RadialMenuProps
@@ -168,7 +168,15 @@ end
RegisterNUICallback('radialClick', function(index, cb) RegisterNUICallback('radialClick', function(index, cb)
cb(1) cb(1)
local item = (currentRadial and currentRadial.items or menuItems)[index + 1] local itemIndex = index + 1
local item, currentMenu
if currentRadial then
item = currentRadial.items[itemIndex]
currentMenu = currentRadial.id
else
item = menuItems[itemIndex]
end
if item.menu then if item.menu then
if currentRadial then if currentRadial then
@@ -180,7 +188,7 @@ RegisterNUICallback('radialClick', function(index, cb)
lib.hideRadial() lib.hideRadial()
end end
if item.onSelect then item.onSelect() end if item.onSelect then item.onSelect(currentMenu, itemIndex) end
end) end)
RegisterNUICallback('radialBack', function(_, cb) RegisterNUICallback('radialBack', function(_, cb)