Pass the Object's handle to a function

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

Hey guys,

Recently downloaded GoDot and currently trying to get the hang of it. I’m having a small issue right now which I cannot wrap my head around at the moment.

I attach this signal to call a function on each button:

for button in self.find_node("VBoxContainer").get_children():
	button.connect("pressed", self, "_checkstatus", [button.get_index()], button)

And this is my function:

func _checkstatus(btn, handle):
    handle.add_color_override("font_color", Color("00F000"))
    	match buttonstate[btn]["status"]:
    			buttonstate[btn]["status"] = "true"
    			buttonstate[btn]["status"] = "false"

Passing the [btn] variable which is used as an index for my array is working like a charm, however trying to pass the “handle” variable which will let me change the font_color returns the following error:

Invalid type in function 'connect' in base 'Button'. Cannot convert argument 5 from Object to int. 

How would I go about doing this?

:bust_in_silhouette: Reply From: Dynx

Hey guys, I actually just found the solution.

For future reference:

Instead of:

button.connect("pressed", self, "_checkstatus", [button.get_index()], button)

You have to pass parameters like this I guess (within ):

button.connect("pressed", self, "_checkstatus", [button.get_index(), button])