From d814521844284d2e6a7095975d0a88a0dcb4510b Mon Sep 17 00:00:00 2001 From: Themba Mahlangu <113313364+ThembaMahlangu@users.noreply.github.com> Date: Sun, 4 May 2025 13:41:12 +0200 Subject: [PATCH] fix(menu): Improve menu focus handling and alt-key reliability --- client/main.lua | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/client/main.lua b/client/main.lua index b394a6b..eb5c419 100644 --- a/client/main.lua +++ b/client/main.lua @@ -3,9 +3,15 @@ RegisterNetEvent('QBCore:Client:UpdateObject', function() QBCore = exports['qb-c local headerShown = false local sendData = nil +local menuFocus = false -- Functions +local function setMenuFocus(state) + menuFocus = state + SetNuiFocus(state, state) +end + local function sortData(data, skipfirst) local header = data[1] local tempData = data @@ -27,7 +33,7 @@ local function openMenu(data, sort, skipFirst) end end end - SetNuiFocus(true, true) + setMenuFocus(true) headerShown = false sendData = data SendNUIMessage({ @@ -39,7 +45,7 @@ end local function closeMenu() sendData = nil headerShown = false - SetNuiFocus(false) + setMenuFocus(false) SendNUIMessage({ action = 'CLOSE_MENU' }) @@ -70,7 +76,7 @@ end) RegisterNUICallback('clickedButton', function(option, cb) if headerShown then headerShown = false end PlaySoundFrontend(-1, 'Highlight_Cancel', 'DLC_HEIST_PLANNING_BOARD_SOUNDS', 1) - SetNuiFocus(false) + setMenuFocus(false) if sendData then local data = sendData[tonumber(option)] sendData = nil @@ -102,7 +108,7 @@ end) RegisterNUICallback('closeMenu', function(_, cb) headerShown = false sendData = nil - SetNuiFocus(false) + setMenuFocus(false) cb('ok') TriggerEvent("qb-menu:client:menuClosed") end) @@ -110,8 +116,8 @@ end) -- Command and Keymapping RegisterCommand('playerfocus', function() - if headerShown then - SetNuiFocus(true, true) + if headerShown and not menuFocus then + setMenuFocus(true) end end)