This.node.on('mouseenter') and mouseleave

Hi,

When I try to create a hover effect on something that is not a button it’s quite buggy.

If you run:

this.node.on('mouseenter', () => {
  cc.log('mouseenter');
})

this.node.on('mouseleave', () => {
  cc.log('mouseleave');
})

You will get in console log:

mouseenter
mouseleave
mouseenter
mouseleave
mouseenter
mouseleave

by moving the cursor over the element like a mousemove, both triggers.

How should i create the correct hover effect on a node?

This is an acknowledged bug.
Check this:

Try with different Creator version, and it will be solved. I think 1.7 had this issue, not sure if it is fixed in that,
but this issue is not present in 1.8, but it had FPS issues.
So choose what suits u best. maybe 1.6.1 or 1.6.2 ?

Thank you for your response!

I’m actually using version 1.8 of cocos creator and the issue is still present there. I haven’t even tried it with other versions of cocos creator.

The issue is exactly what you are writing about in the last comment of the other thread you linked.

You say you have it working in CC1.8? Wonder why I still get this bug in it. I guess I have to debug it some more.

Nope. I remembered that this issue wasn’t present in 1.8 at the time.
Can’t be too sure about it.
I stayed on 1.6 versions and was waiting for this to be solved (with FPS issue).
And btw 1.8.1 has released but I don’t see the change-logs posted here on forum.

Thanks again! Hover is not a deal-breaker for me, but seems like a quite general use-case for many things.

I will try out the latest version!

Have a nice weekend! :slight_smile: :sun_with_face: