mouse_entered on Area2D doesn't work when overlapping a ColorRect

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

Hello !

I want to highlight a sprite when the mouse is over it, so my idea is to put the Sprite into an Area2D, attach to the Area2D a CollisonShape2D and connect the signals mouse_entered and mouse_exited to know if I have to highlight the sprite or not.

The issue is, if those nodes are under a ColorRect (or also under a ReferenceRect), the mouse_entered signal is not fired if the mouse enters the CollisonShape2D where it overlaps the ColorRect/ReferenceRect.

I don’t know if it’s possible to prevent that ?
I saw the property “Mouse > Filter” in the ColorRect’s inspector, and if I set it to ignore, the ColorRect signals about mouse_entered/mouse_exited are not fired but it doesn’t change anything about the Area2D :confused:

I’m still a newbie with Godot, I hope somebody could help me or tell me if I’m doing that wrong. Thanks !

Setting mouse_filter to ignore or pass actually should work. Perhaps collision shapes have different ways of detecting mouse. Would’nt it be easier if You used some Control node inheritant instead of Area and Collision Shape for your Sprite ? All COntrol nodes detect mouse and they won’t compete with each other when mouse_filters are correctly set.

Inces | 2022-01-14 07:51

Indeed, I tried again and set it to ignore works as expected ! I don’t know what I did the first time I tried this but for sure, I did it wrong…
Thank you a lot for your help !

Zombixel | 2022-01-14 20:31