I am trying to create a dynamic UI where elements open on top of each other. Works so far except for a problem where no matter what I put on top of a Text Input, the text input always gets clicked. Can anyone tell me how to fix this?
Thanks in advance
Have you checked the MouseFilter documentation?
Depending on what you need, you can either disable mouse input on your text, or block it completely on the elements that are on top.
The problem is that to use this I will need to create an entire system to detect if a control node is obscured by a different one.
What I hope to find out is why a Text Input receives an input even though a Button is on top of it
I don’t know what you’re trying to do, but I’m not sure you need to “create an entire system” as there are some existing tools. Again, have you read the documentation about Mouse filtering on Control nodes? The enum MOUSE_FILTER_STOP does exactly what you’re asking for:
The control will receive mouse movement input events and mouse button input events if clicked on through _gui_input(). The control will also receive the mouse_entered and mouse_exited signals. These events are automatically marked as handled, and they will not propagate further to other controls. This also results in blocking signals in other controls.
Ensure your node hierarchy is set correctly so that the button that’s on top of your text should catch the input, based on Controls behaviours, and if not, it would be useful that you attach some screenshots to make the problem more clear
The problem is that since my UI is dynamic I can’t know in advance what Nodes are going to overlap each other so I can’t know in advance what Nodes’ Mouse Filter I need to change.
As for screenshots, I don’t know how to do it aside from Print Screen and in Windows 11 it requires the use of the mouse so I can’t show you how the mouse react, and this forum won’t allow me to upload a video.
I must be missing something, but why would you need to change the mouse filters on controls at runtime, even with a dynamic UI? You always want your text input to receive mouse input if nothing is on top of it, and not receive inputs whatever object is above, right?
This kind of behaviour is supposed to work naturally by using mouse filters, but you don’t have to change. I just tried putting two buttons on top of each other, both with their mouse filter set to Stop, and only the button above receives my mouse input.
About screenshots, I think that a simple example of what your dynamic UI looks like and why it’s making the input system is troublesome would help a lot!
Sorry for the headache, but something I did(couldn’t for the life of me tell you what) resolved the issue. I can’t even recreate it now to try and understand what happened so I guess it’s resolved.
Thank you for the help anyway!