We (a friend and I) are having the following problem at making an interactive loading screen. We used the manual loading screen shutdown function to make sure that we can stop and unload the loading screen ourselves when needed. But after when the game is done loading and the loading screen is still “active” (because we deliberately keep it on) the JavaScript DOM events don’t work anymore.
It makes no difference if we use the mouse tracking events or the key events. Although (strangely), when we make a loading screen nui call to the nui page these (nui)events do work. And when we do a check if the DOM is still active we do get a positive value back.
Now the question!
Does anybody know how we can make use of the DOM events after the game is done loading?
We saw in the master branch in the Cfx/Fivem github that there’s a convar incoming that can enable the cursor in the loading screen. Is this perhaps a solution to our problem?
I never extended the loading screen further than it self wants to. But I was playing around with UIs which open up right after the loading screen and even during loading. While the mouse was active during loading I had to call setNuiFocus(true,true) after the loading was done. Only then my mouse and the events occured.
Thanks for you answer. Sadly this was not the solution. Because when we try this as first thing in the script we get an error back with the text “script:game:nui - Autofocus processing was blocked because a document already has a focused element.” . And still nothing works after this. Which gives me the impression that the loading screen never lost it’s focus or somehow has a different kind of focus than a normal nui. But there is no evidence of that in the fivem source code. So we are really in the dark here.
I suspect the loading screen frame never really gets explicit focus via the focus stack system used for resources and resources starting then stack on top of the loading screen, breaking iframe z-index.
Can someone confirm if the same happens when starting a new resource atop a focused resource?
The default chat script was the only script that needed a nui to be loaded. When the game finished loading the chat iframe was loaded to. Which resulted in a loading screen that was out of focus.
To answer the question asked by @nta. Yes, when starting a new resource on top of a focused resource will result in lost focus loading screen.