Passing property of group member as argument in call_group()

Godot Version

4.5.1

Question

Is there any way to pass the property value of each node inside the group as an argument for the method being called in "call_group"?

Let’s say I have a group of buttons and I want to connect their “pressed” signals to a method (let’s call it "methodX”) on a given node (let’s call it “nodeX”). Although “pressed” don’t carry parameters, I want to pass one anyway (using “bind”), the parameter being a property of the button that is emitting the signal.

If I wanted to do this with only one button, I would write (in “nodeX”):

button.connect ( "pressed" , methodX.bind(button.property) )

But how can I do this with all the buttons at once, using “call_group”?

I imagined something like this (in “nodeX”), where “member” is a reference for each member of the buttons group:

get_tree().call_group( "buttons_group" , connect, "pressed", methodX.bind( member.property) )

I know that there are other ways to solve this. The first that comes to mind is iterating trough each element with a “for loop” and “get_nodes_in_group” (which might be better considering that i could call “connect” from the signal). I could also use a custom signal that carries the property as a parameter. Nonetheless, I want to know if there is any way to do this with “call_group” and without changing the signal being used.

Thanks. I hope I’m being clear.

You can’t do it that way. call_group takes the method name, not a Callable. You could do it if each button implemented a method that connects itself and then call that method. Otherwise use a regular loop or Array::any()/all()

Got it. I’ve never thought about the difference between passing a Callable and passing a method’s name, gonna look into that

Thanks!