Jump to content

How to fix cursor being stuck in hand mode


CorayThan
 Share

Recommended Posts

I have a bunch of buttons I'm using, and with some of them I destroy or disable them after they are clicked. They also use a hand cursor on hover. When I destroy them, the game seems to reset to the pointer just fine, but when I disable the input and turn off the hand cursor, it seems to get stuck on the hand cursor for the entire canvas.

So basically, if I have a sprite with 

this.button.input.useHandCursor = true

Then in the onClick I set that to false, the hand cursor doesn't go away. Does anyone know a way to manually change the cursor, or fix it so it changes properly by itself?

I've tried

document.getElementById("game").style.cursor = "auto"

where "game" is the div I'm setting the phaser game in, but that doesn't change anything.

Link to comment
Share on other sites

You probably shouldn't set useHandCursor=false from within a button handler because then Phaser won't know to remove the hand cursor later.

See https://samme.github.io/phaser-examples-mirror/buttons/disable button on click.html. The hand cursor disappears when the button is disabled.

If you have to reset the cursor manually, it's 

game.canvas.style.cursor = '';

 

Link to comment
Share on other sites

Ah, that fixes it, thanks! That's curious though that you aren't setting handCursor=true at all and you're getting the hand cursor. That isn't working for me. Also thanks for the advice about resetting the cursor. With this working I won't need that for now, but maybe later.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...