How can I use NUI focus exclusively with the mouse?

How can I use NUI focus exclusively with the mouse?


I’m creating a script that has a functionality similar to a cellphone, but I encountered a problem with the native function SetNuiFocus() in FiveM.

--SetNuiFocus
SetNuiFocus(hasFocus boolean, hasCursor boolean)

If I pass (true, true) as parameters, it adds focus to the interface, but the player is unable to move using W, A, S, D, etc.

SetNuiFocus(true, true)

If I pass (true, false), it adds focus to the NUI, but the mouse is not enabled to interact with the interface.

SetNuiFocus(true, false)

If I pass (false, true), it doesn’t add focus to the interface, it remains as if I had passed (false, false) as parameters.

SetNuiFocus(false, true)

Functions that I discovered by researching in other topics and tried to use:

I tried to use the function SetNuiFocusKeepInput(), however, this function doesn’t affect anything other than enabling or disabling the keyboard, as far as I noticed when using it.

--SetNuiFocusKeepInput
SetNuiFocusKeepInput(keepInput boolean)

If I pass (false) as a parameter, regardless of the sequence of parameters passed in the SetNuiFocus() function, the keyboard remains disabled.

SetNuiFocusKeepInput(false)

Are you sure you’re not disable the control keys elsewhere? SetNuiFocusKeepInput should keep keyboard input

From what I understand, I say that I haven’t disabled it anywhere else, but to make sure, the code I am using is as follows:

-- client-side code
RegisterCommand('test', function()
    SetNuiFocus(true, true)
    SetNuiFocusKeepInput(false)
end)

But as I mentioned, I tested different parameter situations, but it didn’t work.

Is it necessary to select an interface in order to add focus?