feat(web/context): Get open context menu function

This commit is contained in:
Luke
2022-04-15 10:22:28 +02:00
parent 65a5bab623
commit 50b1ddd167

View File

@@ -1,7 +1,9 @@
local contextMenus = {} local contextMenus = {}
local openContextMenu = nil
function lib.showContext(id) function lib.showContext(id)
local data = contextMenus[id] local data = contextMenus[id]
openContextMenu = id
SetNuiFocus(true, true) SetNuiFocus(true, true)
SendNUIMessage({ SendNUIMessage({
action = 'showContext', action = 'showContext',
@@ -24,6 +26,8 @@ function lib.registerContext(context)
end end
end end
function lib.getOpenContextMenu() return openContextMenu end
RegisterNUICallback('openContext', function(id, cb) RegisterNUICallback('openContext', function(id, cb)
cb(1) cb(1)
lib.showContext(id) lib.showContext(id)
@@ -33,6 +37,7 @@ RegisterNUICallback('clickContext', function(data, cb)
cb(1) cb(1)
if data.event then TriggerEvent(data.event, data.args) end if data.event then TriggerEvent(data.event, data.args) end
if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end if data.serverEvent then TriggerServerEvent(data.serverEvent, data.args) end
openContextMenu = nil
SetNuiFocus(false, false) SetNuiFocus(false, false)
SendNUIMessage({ SendNUIMessage({
action = 'hideContext' action = 'hideContext'