feat(interface/context): context menu onBack function (#122)

* feat(interface/context): back button pressed

* fix(context): types
This commit is contained in:
Sam Shanks
2022-10-11 12:48:59 +01:00
committed by GitHub
parent 10acd71135
commit 2813bb288b
4 changed files with 7 additions and 4 deletions

View File

@@ -22,6 +22,7 @@ local openContextMenu = nil
---@field title string
---@field menu? string
---@field onExit? fun()
---@field onBack? fun()
---@field canClose? boolean
---@field options { [string]: ContextMenuItem } | ContextMenuArrayItem[]
@@ -68,9 +69,10 @@ function lib.getOpenContextMenu() return openContextMenu end
---@param onExit boolean?
function lib.hideContext(onExit) closeContext(nil, nil, onExit) end
RegisterNUICallback('openContext', function(id, cb)
RegisterNUICallback('openContext', function(data, cb)
if data.back and contextMenus[openContextMenu].onBack then contextMenus[openContextMenu].onBack() end
cb(1)
lib.showContext(id)
lib.showContext(data.id)
end)
RegisterNUICallback('clickContext', function(id, cb)