mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-19 07:56:02 +01:00
feat(interface/menu): onClose keyPressed
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
---@type { [string]: MenuProps }
|
||||||
local registeredMenus = {}
|
local registeredMenus = {}
|
||||||
|
---@type MenuProps | nil
|
||||||
local openMenu = nil
|
local openMenu = nil
|
||||||
local keepInput = IsNuiFocusKeepingInput()
|
local keepInput = IsNuiFocusKeepingInput()
|
||||||
|
|
||||||
@@ -19,7 +21,8 @@ local keepInput = IsNuiFocusKeepingInput()
|
|||||||
---@field options MenuOptions[]
|
---@field options MenuOptions[]
|
||||||
---@field position? MenuPosition
|
---@field position? MenuPosition
|
||||||
---@field disableInput? boolean
|
---@field disableInput? boolean
|
||||||
---@field onClose? fun()
|
---@field canClose? boolean
|
||||||
|
---@field onClose? fun(keyPressed?: 'Escape' | 'Backspace')
|
||||||
---@field onSelected? MenuChangeFunction
|
---@field onSelected? MenuChangeFunction
|
||||||
---@field onSideScroll? MenuChangeFunction
|
---@field onSideScroll? MenuChangeFunction
|
||||||
|
|
||||||
@@ -45,7 +48,7 @@ function lib.showMenu(id, startIndex)
|
|||||||
if not openMenu then
|
if not openMenu then
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
while openMenu do
|
while openMenu do
|
||||||
if not openMenu.disableInput then
|
if openMenu.disableInput == nil or openMenu.disableInput then
|
||||||
DisablePlayerFiring(cache.playerId, true)
|
DisablePlayerFiring(cache.playerId, true)
|
||||||
HudWeaponWheelIgnoreSelection()
|
HudWeaponWheelIgnoreSelection()
|
||||||
DisableControlAction(0, 140, true)
|
DisableControlAction(0, 140, true)
|
||||||
@@ -165,6 +168,6 @@ RegisterNUICallback('closeMenu', function(data, cb)
|
|||||||
openMenu = nil
|
openMenu = nil
|
||||||
|
|
||||||
if menu.onClose then
|
if menu.onClose then
|
||||||
menu.onClose()
|
menu.onClose(data --[[@as 'Escape' | 'Backspace' | nil]])
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
Reference in New Issue
Block a user