refactor(client/interface): nui focus consistency

This commit is contained in:
Linden
2023-03-23 05:55:16 +11:00
parent 9413f9dae8
commit c4b87a0d91
4 changed files with 19 additions and 15 deletions

View File

@@ -15,9 +15,8 @@ function lib.alertDialog(data)
if alert then return end
alert = promise.new()
lib.setNuiFocus(false)
SetNuiFocus(true, true)
SetNuiFocusKeepInput(false)
SendNUIMessage({
action = 'sendAlert',
data = data
@@ -33,8 +32,8 @@ function lib.closeAlertDialog()
SendNUIMessage({
action = 'closeAlertDialog'
})
alert:resolve(nil)
alert:resolve(nil)
alert = nil
end

View File

@@ -38,7 +38,7 @@ function lib.inputDialog(heading, rows, options)
end
end
SetNuiFocus(true, true)
lib.setNuiFocus(false)
SendNUIMessage({
action = 'openDialog',
data = {
@@ -53,18 +53,22 @@ end
function lib.closeInputDialog()
if not input then return end
input:resolve(nil)
input = nil
SetNuiFocus(false, false)
lib.resetNuiFocus()
SendNUIMessage({
action = 'closeInputDialog'
})
input:resolve(nil)
input = nil
end
RegisterNUICallback('inputData', function(data, cb)
cb(1)
SetNuiFocus(false, false)
lib.resetNuiFocus()
local promise = input
input = nil
promise:resolve(data)
end)

View File

@@ -120,8 +120,7 @@ function lib.hideRadial()
data = false
})
SetNuiFocus(false, false)
SetNuiFocusKeepInput(false)
lib.setNuiFocus(true)
table.wipe(menuHistory)
isOpen = false
@@ -266,7 +265,7 @@ RegisterNUICallback('radialClose', function(_, cb)
if not isOpen then return end
SetNuiFocus(false, false)
lib.resetNuiFocus()
isOpen = false
currentRadial = nil
@@ -314,8 +313,8 @@ lib.addKeybind({
items = menuItems
}
})
SetNuiFocus(true, true)
SetNuiFocusKeepInput(true)
lib.setNuiFocus(false)
SetCursorLocation(0.5, 0.5)
while isOpen do

View File

@@ -10,7 +10,7 @@ function lib.skillCheck(difficulty, inputs)
if skillcheck then return end
skillcheck = promise:new()
SetNuiFocus(true, false)
lib.setNuiFocus(false, true)
SendNUIMessage({
action = 'startSkillCheck',
data = {
@@ -24,9 +24,11 @@ end
RegisterNUICallback('skillCheckOver', function(success, cb)
cb(1)
if skillcheck then
lib.resetNuiFocus()
skillcheck:resolve(success)
skillcheck = nil
SetNuiFocus(false, false)
end
end)