mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 23:46:03 +01:00
feat(client/radial): return currentMenu and itemIndex onSelect
This commit is contained in:
@@ -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;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user