Make cursor hidden in MOUSE_MODE_CONFINED

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IntCaster

Is there another way to hide the windows cursor other than MOUSE_MODE_HIDDEN.
I need the functionality of MOUSE_MODE_CONFINED but with the windows cursor hidden as i have my own cursor Sprite following the mouse, so MOUSE_MODE_CAPTURED doesnt work as well.

I’m not aware of another way. Though, from the docs, MOUSE_MODE_CAPTURED sounds like what you want. Though, since you mention it doesn’t work well, can you explain where it falls short?

jgodfrey | 2020-02-09 00:53

MOUSE_MODE_CAPTURED always centers the mouse in the middle of the screen so i cant interact with texturebutton nodes correctly

IntCaster | 2020-02-09 02:48

Hmmm… Yeah, a quick test here shows the same thing (in captured mode, the mouse always reports a single point at the center of the screen).

I’m really not familiar with the details of the MouseMode settings, but MOUSE_MODE_CAPTURED doesn’t seem to work as it’s documented.

While I’m not sure, that feels like a Godot bug.

jgodfrey | 2020-02-09 04:10

is there any “easy” way to view/change the c++ implentation of the gdscript set mouse mode function?

IntCaster | 2020-02-09 16:23

:bust_in_silhouette: Reply From: Sween123

Go to Project Settings - Display - Mouse Cursor - Custom Image
Load the texture there, and you will have the new cursor sprite replacing the original cursor.

EDITED:
Can also use this in code:

Input.set_custom_mouse_cursor(Your Sprite)

tried that as well but it seems to ignore opacity/alpha so i cant make it transparent the size restriction also prevents me from replicating the sprite :S

IntCaster | 2020-02-09 15:14

Use this:

Input.set_custom_mouse_cursor(Your Sprite)

You can load your sprite in code where your sprite can be the scene you created. You can change properties like opacity anytime you want.

Sween123 | 2020-02-09 15:24

its the same thing when setting it in project settings, but it doesnt hide the cursor. setting it to an empty sprite or alpha=0 just makes it white/inverse. mby you used linux? iguess its a windows problem if it works for you then

IntCaster | 2020-02-09 16:15

Oh right. That’s because it’s not a sprite but a resource actually.
You can edit your mouse cursor texture maybe in ps, one for normal, one for transparent. Reset the mouse cursor sprite to what you want it to be as the program goes.

Sween123 | 2020-02-09 23:31