Dynamically connecting a signal to a dynamically created node

Godot Version


I created a checkbox that adds each line created to it one by one. This allows for unlimited options that are created by the user one by one. I’ve run into a problem where I cannot connect it to a toggle function which would detect when the state of the checkbox(checked or unchecked) and change the value for its “checked” key to true/false. This is because the toggle function requires the toggle signal which I cannot reproduce dynamically. I tried using connect this way: child.connect(“toggled”, self, “_on_check_box_toggled”)

change to:

child.connect("toggled", self, _on_check_box_toggled)

I tried that but it says it wants the second argument to be a callable and the last one must be a “flag” int value

ok i forgot, it’s not godot 3

child.connect("toggled", _on_check_box_toggled)

this should do it

1 Like

I’ve learned a lot with that answer alone

1 Like

alternatively you can also do like this


or even

1 Like

These were even better because I could add another argument to it

You can add more parameters with bind, see the example in the reference