Until we get standardized mouse support, here’s a little script you can use as an example in the meanwhile.
It gets the mouse position from in-game, and then fires .focus() and .click() events on the HTML elements it finds under the cursor position in the UI.
This is for DEVS, as an example. So please, if you’re not developing a script, don’t ask how to “install this mod”
This also freezes the camera movement, and blocks the left mouse button, so that it can be used for the UI, without interfering with the game input.
Exit the UI by pressing the escape key. Make sure you do this before you stop/restart the resource, otherwise you get stuck. Not a problem with this script, it’s a problem with the whole UI thing.
Code should be self-explanatory, but if you have any questions, feel free to ask.
I just added my chat resource to the repo, you may have to modify yours/use mine, for the chat commands to work.
Also, this has limitations. All it does, is execute a .focus() and .click() on the HTML element at the position of your cursor.
This means that iframes will not work. Because iframes are protected, and prevent any JavaScript input from the browser.
Also things like selecting text with the mouse will not work.
The solution is not ideal, but it’ll do for now.
Citizen.CreateThread(function()
while true do
if guiEnabled then
DisableControlAction(0, 1, guiEnabled) -- LookLeftRight
DisableControlAction(0, 2, guiEnabled) -- LookUpDown
DisableControlAction(0, 142, guiEnabled) -- MeleeAttackAlternate
DisableControlAction(0, 106, guiEnabled) -- VehicleMouseControlOverride
if IsDisabledControlJustReleased(0, 142) then -- MeleeAttackAlternate
SendNUIMessage({
type = "click"
})
end
end
Citizen.Wait(0)
end
end)
I really like this resource, it makes creating menus really easy. I noticed you said selecting text will not work, what abut clicking a button? I’m trying to do this.
Hey, so I need some help. I’m working on making the menu for VRP use a mouse and not the arrow-keys. I’ve tried everything I know how to do. I want the mouse enabled when you press the menu key. If anyone can help that’d be awesome.