Jump to content

Mouseover cursor pointer if already over sprite


Recommended Posts

I have a sprite with .useHandCursor = true and events.onInputOver.add(this.OnMouseOver, this);

BUT: If the mouse is already over the sprite I have to move it out and back again for the event to trigger. 

Now this is not a problem becouse I can rectangle.contain check the mouse cursors position when my button shows but that is only a graphical change. I need to also change the cursor to pointer. I also got this to work but I have to move the cursor (atleast 1 pixel) for the cursor to change.

Is this a browser/html thing? If not how could I instantly change the cursor?

Link to comment
Share on other sites

Check to see if the mouse is over the sprite and if it is, you can manually force the hand cursor by doing something like this:

this.game.canvas.style.cursor = "pointer";
sprite._setHandCursor = true;

I'm not totally sure on the second line, but you might need to include it so that the sprite knows it's using pointer and needs to turn it off on mouse out.

Link to comment
Share on other sites

Thank you for the response but there is no such command as setHandCursor. (And I am using a Graphic as a button background withing a Group anyways)

And yeah, I am already using the first line which only changes the cursor to pointer if i move the mouse atleast 1 pixel.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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