mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
refactor(client/interface): nui focus consistency
This commit is contained in:
@@ -15,9 +15,8 @@ function lib.alertDialog(data)
|
|||||||
if alert then return end
|
if alert then return end
|
||||||
|
|
||||||
alert = promise.new()
|
alert = promise.new()
|
||||||
|
|
||||||
lib.setNuiFocus(false)
|
lib.setNuiFocus(false)
|
||||||
SetNuiFocus(true, true)
|
|
||||||
SetNuiFocusKeepInput(false)
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'sendAlert',
|
action = 'sendAlert',
|
||||||
data = data
|
data = data
|
||||||
@@ -33,8 +32,8 @@ function lib.closeAlertDialog()
|
|||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'closeAlertDialog'
|
action = 'closeAlertDialog'
|
||||||
})
|
})
|
||||||
alert:resolve(nil)
|
|
||||||
|
|
||||||
|
alert:resolve(nil)
|
||||||
alert = nil
|
alert = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ function lib.inputDialog(heading, rows, options)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
SetNuiFocus(true, true)
|
lib.setNuiFocus(false)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'openDialog',
|
action = 'openDialog',
|
||||||
data = {
|
data = {
|
||||||
@@ -53,18 +53,22 @@ end
|
|||||||
|
|
||||||
function lib.closeInputDialog()
|
function lib.closeInputDialog()
|
||||||
if not input then return end
|
if not input then return end
|
||||||
input:resolve(nil)
|
|
||||||
input = nil
|
lib.resetNuiFocus()
|
||||||
SetNuiFocus(false, false)
|
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'closeInputDialog'
|
action = 'closeInputDialog'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
input:resolve(nil)
|
||||||
|
input = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNUICallback('inputData', function(data, cb)
|
RegisterNUICallback('inputData', function(data, cb)
|
||||||
cb(1)
|
cb(1)
|
||||||
SetNuiFocus(false, false)
|
lib.resetNuiFocus()
|
||||||
|
|
||||||
local promise = input
|
local promise = input
|
||||||
input = nil
|
input = nil
|
||||||
|
|
||||||
promise:resolve(data)
|
promise:resolve(data)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -120,8 +120,7 @@ function lib.hideRadial()
|
|||||||
data = false
|
data = false
|
||||||
})
|
})
|
||||||
|
|
||||||
SetNuiFocus(false, false)
|
lib.setNuiFocus(true)
|
||||||
SetNuiFocusKeepInput(false)
|
|
||||||
table.wipe(menuHistory)
|
table.wipe(menuHistory)
|
||||||
|
|
||||||
isOpen = false
|
isOpen = false
|
||||||
@@ -266,7 +265,7 @@ RegisterNUICallback('radialClose', function(_, cb)
|
|||||||
|
|
||||||
if not isOpen then return end
|
if not isOpen then return end
|
||||||
|
|
||||||
SetNuiFocus(false, false)
|
lib.resetNuiFocus()
|
||||||
|
|
||||||
isOpen = false
|
isOpen = false
|
||||||
currentRadial = nil
|
currentRadial = nil
|
||||||
@@ -314,8 +313,8 @@ lib.addKeybind({
|
|||||||
items = menuItems
|
items = menuItems
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
SetNuiFocus(true, true)
|
|
||||||
SetNuiFocusKeepInput(true)
|
lib.setNuiFocus(false)
|
||||||
SetCursorLocation(0.5, 0.5)
|
SetCursorLocation(0.5, 0.5)
|
||||||
|
|
||||||
while isOpen do
|
while isOpen do
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ function lib.skillCheck(difficulty, inputs)
|
|||||||
if skillcheck then return end
|
if skillcheck then return end
|
||||||
skillcheck = promise:new()
|
skillcheck = promise:new()
|
||||||
|
|
||||||
SetNuiFocus(true, false)
|
lib.setNuiFocus(false, true)
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
action = 'startSkillCheck',
|
action = 'startSkillCheck',
|
||||||
data = {
|
data = {
|
||||||
@@ -24,9 +24,11 @@ end
|
|||||||
|
|
||||||
RegisterNUICallback('skillCheckOver', function(success, cb)
|
RegisterNUICallback('skillCheckOver', function(success, cb)
|
||||||
cb(1)
|
cb(1)
|
||||||
|
|
||||||
if skillcheck then
|
if skillcheck then
|
||||||
|
lib.resetNuiFocus()
|
||||||
|
|
||||||
skillcheck:resolve(success)
|
skillcheck:resolve(success)
|
||||||
skillcheck = nil
|
skillcheck = nil
|
||||||
SetNuiFocus(false, false)
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user