client
SetNuiFocus
FiveM client native documentation with a Lua example.
Summary
Gives or removes keyboard/mouse focus for a NUI (HTML UI). Essential for any interactive menu built in NUI — without it the cursor won't work.
Returns
void
Parameters
hasFocusbooleanWhether the NUI has keyboard focus.hasCursorbooleanWhether to show the mouse cursor.Example
SetNuiFocus(true, true) -- open menu: focus + cursor
-- on close:
SetNuiFocus(false, false)Common pitfalls
- Forgetting SetNuiFocus(false,false) on close traps the player's cursor — a very common NUI bug.
- Only give focus while the UI is actually open.
Related natives
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →