mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
feat(web/context): Get open context menu function
This commit is contained in:
@@ -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'
|
||||||
|
|||||||
Reference in New Issue
Block a user