Hi,

I've been looking at the documentation for signals, and I'm having trouble figuring out why Godot isn't allowing me to pass in a target_instance. The error I'm getting is this:

Error connect(signal: stringName, callable: Callable, flags: int = 0)

The code that Godot considers correct is this:

for i in self.get_children():
		i.connect("SELECT_ITEM", self.OnSelectItem())

If I try to write instead this:

for i in self.get_children():
		i.connect("SELECT_ITEM", self, self.OnSelectItem())

I get an error that argument 2 isn't callable.

I feel like I'm missing something obvious but I've been stuck on this for over an hour. If it's relevant, I am using Godot 4 in Beta, although I'd think something this basic wouldn't be different.

  • It was changed to use the Signal and Callable classes, to avoid using strings.
    The new syntax would be

    for i in get_children():
        i.SELECT_ITEM.connect(OnSelectItem)

    more generally

    object.signal.connect(object.method.bind(arguments))

It was changed to use the Signal and Callable classes, to avoid using strings.
The new syntax would be

for i in get_children():
    i.SELECT_ITEM.connect(OnSelectItem)

more generally

object.signal.connect(object.method.bind(arguments))