Area2D or Button don't detect the mouse properly

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

I have a game over screen in my project, that includes a try again button. I tried making it with area2D and a collision shape, with a variable mouse_over controlled by the mouse_entered and mouse_exited signals and then emitting a signal whenever the mouse was clicked and mouse_over was true.
However, most of the time, the area2D didn’t detect the mouse and when it did, it was only on the edges of the collision shape - i had it print “mouse entered” and “mouse_exited” in the respective functions and found out that when I moved the mouse to the edge of the collision shape, it called the function mouse_entered, but when I moved it a bit inward, it called mouse_exited, even though in reality it didn’t exit the collision shape. It behaved as if it was a hollow collision polygon. And that was only sometimes - sometimes the functions weren’t called at all.
I tried replacing the Area2D node with a Button node (and of course altering the code to fit the Button node), which now worked every time (there wasn’t a time when it wouldn’t click at all) but it still only works on the edges of the button, even though the button spans the entire size off itself.

Any thoughts on what is causing this or how to fix it?

Thanks,
-Mymokol

:bust_in_silhouette: Reply From: exuin

Is it possible that you have something covering the button? I’ve had that problem before. The docs say this:

Sets mouse_filter to MOUSE_FILTER_IGNORE to tell a Control node to ignore mouse or touch events. You’ll need it if you place an icon on top of a button.