Buttons stop working when they are children of a Grid Container node

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

In my scene tree, I have these buttons that I add at runtime via code. They are a packed scene made of a button node with an animated sprite attached to it. I’m adding 20 of them and I want them to be arranged in a grid layout.

The buttons by themselves work fine, and they also work fine if I add them as children of any type of control node (they are added as intended, they receive input as intended). But when their parent is a Grid Container, they stop working : they are added as expected in a grid like layout but they can’t receive mouse input anymore…

I’ve tried every mouse filter, but the buttons never receive the mouse input when they are children of a grid container.

The thing is, when I use right click on my Grid Container node to change its type to any other control node, the buttons now work (though nothing else has changed in the scene).

So to summarize, the buttons work as long as their parent is anything but a Grid Container. I have no idea what’s causing this, and after 2 weeks of trying, I’m out of ideas to try…
I used the debugger to check what’s receiving the mouse input : when mouse filter is set to “pass” on the grid container, the grid container will receive the input (not the buttons), and when it’s set to “ignore”, the input will not be handled (the debugger will display the last control clicked). The button mouse filter is always set to “stop”.

I should also add that every other control work in the scene, and the same buttons work fine when I change my grid container node to a simple control node

Thank you to anyone who could help me with this