Skip to content

Commit

Permalink
feat(interface/menu): onClose keyPressed
Browse files Browse the repository at this point in the history
  • Loading branch information
BerkieBb authored Sep 25, 2022
1 parent c47741a commit 615a3cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions resource/interface/client/menu.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---@type { [string]: MenuProps }
local registeredMenus = {}
---@type MenuProps | nil
local openMenu = nil
local keepInput = IsNuiFocusKeepingInput()

Expand All @@ -19,7 +21,8 @@ local keepInput = IsNuiFocusKeepingInput()
---@field options MenuOptions[]
---@field position? MenuPosition
---@field disableInput? boolean
---@field onClose? fun()
---@field canClose? boolean
---@field onClose? fun(keyPressed?: 'Escape' | 'Backspace')
---@field onSelected? MenuChangeFunction
---@field onSideScroll? MenuChangeFunction

Expand All @@ -45,7 +48,7 @@ function lib.showMenu(id, startIndex)
if not openMenu then
CreateThread(function()
while openMenu do
if not openMenu.disableInput then
if openMenu.disableInput == nil or openMenu.disableInput then
DisablePlayerFiring(cache.playerId, true)
HudWeaponWheelIgnoreSelection()
DisableControlAction(0, 140, true)
Expand Down Expand Up @@ -165,6 +168,6 @@ RegisterNUICallback('closeMenu', function(data, cb)
openMenu = nil

if menu.onClose then
menu.onClose()
menu.onClose(data --[[@as 'Escape' | 'Backspace' | nil]])
end
end)
end)

0 comments on commit 615a3cc

Please sign in to comment.