The mouse filters are driving me crazy
Asked Answered
A

11

0

"Regardless of the mouse filter setting I apply, and in any node hierarchy, be it parent-child or child-parent, the mouse event continues to propagate to underlying nodes. I can't make sense of it.

Whether I set it to Ignore or Stop, it still passes inputs.

When a Control node, TextureRect, or ColorRect is the parent of the button, the input gets through, and the button is pressed.

If the button is the parent of the aforementioned nodes, the result is the same.

Can anyone help me understand what's happening with mouse filters in Godot? It seems impossible to see them working as expected."

Agonizing answered 18/11, 2023 at 13:43 Comment(0)
G
0

Agonizing Do you handle events in _gui_input()?

Gayomart answered 18/11, 2023 at 13:56 Comment(0)
A
0

Gayomart no

Agonizing answered 18/11, 2023 at 14:11 Comment(0)
G
0

Agonizing You should use _gui_input() instead of _input(). Unlike the latter, the former obeys control's event filters.

Gayomart answered 18/11, 2023 at 15:39 Comment(0)
K
0

Gayomart You should use _gui_input() instead of _input()

I assume that's only relevant when you're handling the mouse input at a low level. If you're using signals such as Button.button_pressed, then the mouse filter behaves as expected.

Kling answered 18/11, 2023 at 17:15 Comment(0)
G
0

Kling Yeah, my guess from OPs vague description was that they're using _input(). If that's not the case, best to provide exact node setup and event handling code.

Gayomart answered 18/11, 2023 at 17:31 Comment(0)
L
0

Being the parent alone isn't enough, a control has to cover another, spatially, to stop mouse events from propagating down to controls beneath it.

He's saying that because a Control is a child of a Parent with Stop... that he thinks the Stop property would propagate to the children... but that's not how it works. It's just what-covers-what in layered 2D space

Sometimes I just put a large invisible Control with Stop over top of all the controls I want 'disabled'

Lashandralashar answered 18/11, 2023 at 17:36 Comment(0)
G
0

Lashandralashar Being the parent alone isn't enough, a control has to cover another, spatially, to stop mouse events from propagating down to controls beneath it.

I'd assume that's self evident.

Gayomart answered 18/11, 2023 at 17:49 Comment(0)
K
0

Maybe it's not self-evident to the OP, since he mentioned "parent" several times.

Kling answered 18/11, 2023 at 17:54 Comment(0)
G
0

Kling Probably.
Post your exact scene setup and code if you want this resolved Chambermaid, so people don't have to guess.

Gayomart answered 18/11, 2023 at 18:15 Comment(0)
C
0

Gayomart something-something assuming things makes an ass of u 'n me, which is why I go around presuming instead...

Churchly answered 18/11, 2023 at 18:16 Comment(0)
G
0

Churchly This thread is becoming psychoactive. @OP, better provide details or else... 😂

Gayomart answered 18/11, 2023 at 18:31 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.