Add canClose function to context menu

Added a canClose parameter so that the user cannot close the menu by pressing ESC instead has to be force closed via code.
This commit is contained in:
Tony Stark
2022-12-20 23:10:06 +05:30
committed by GitHub
parent d0d2c84186
commit 54088abcb6
+7 -6
View File
@@ -12,10 +12,11 @@ function Post(fn,...)
})
end
function Open(position,eles,onSelect,onClose)
function Open(position,eles,onSelect,onClose,canClose)
activeMenu = {
position = position,
eles = eles,
canClose = canClose,
onSelect = onSelect,
onClose = onClose
}
@@ -74,11 +75,11 @@ end)
-- NUI Callbacks
-- [ closed | selected | changed ]
RegisterNUICallback("closed",function()
if not activeMenu then
return
RegisterNUICallback("closed",function(data,cb)
if not activeMenu or (activeMenu and not activeMenu.canClose) then
return cb(false)
end
cb(true)
Closed()
end)
@@ -266,4 +267,4 @@ if Debug then
exports["esx_context"]:Open(position,eles,onSelect,onClose)
end)
end
end