mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
fix(client/interface): reset nui focus on alert (#192)
This commit is contained in:
@@ -1,4 +1,10 @@
|
||||
local alert = nil
|
||||
local keepInput = IsNuiFocusKeepingInput()
|
||||
|
||||
local function resetFocus()
|
||||
SetNuiFocus(false, false)
|
||||
SetNuiFocusKeepInput(keepInput)
|
||||
end
|
||||
|
||||
---@class AlertDialogProps
|
||||
---@field header string;
|
||||
@@ -13,7 +19,10 @@ function lib.alertDialog(data)
|
||||
if alert then return end
|
||||
alert = promise.new()
|
||||
|
||||
keepInput = IsNuiFocusKeepingInput()
|
||||
|
||||
SetNuiFocus(true, true)
|
||||
SetNuiFocusKeepInput(false)
|
||||
SendNUIMessage({
|
||||
action = 'sendAlert',
|
||||
data = data
|
||||
@@ -26,7 +35,7 @@ function lib.closeAlertDialog()
|
||||
if not alert then return end
|
||||
alert:resolve(nil)
|
||||
alert = nil
|
||||
SetNuiFocus(false, false)
|
||||
resetFocus()
|
||||
SendNUIMessage({
|
||||
action = 'closeAlertDialog'
|
||||
})
|
||||
@@ -35,10 +44,10 @@ end
|
||||
|
||||
RegisterNUICallback('closeAlert', function(data, cb)
|
||||
cb(1)
|
||||
SetNuiFocus(false, false)
|
||||
resetFocus()
|
||||
local promise = alert
|
||||
alert = nil
|
||||
promise:resolve(data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ox_lib:alertDialog', lib.alertDialog)
|
||||
RegisterNetEvent('ox_lib:alertDialog', lib.alertDialog)
|
||||
|
||||
Reference in New Issue
Block a user