Button connect parameters dont work

Godot Version



edit: sorry for the formatting idk why it gets rid of the indents here
Okay so I’ve googled for way too long and even tried to get an answer from ChatGPT but literally nothing helps…
I am creating a new button through a script and want to connect the newly instanciated button to a “pressed” function including parameters. When doing so it tells me that either it wants only integers (I have to use strings) or that it is for some reason not callable?
The button itself works, I’ve tried it with a simple print().
Please help me, I am really freaking out because of this.

My code:
extends Control

var itemsLoad = [
func _ready():
for i in itemsLoad.size():
var item := InventoryItem.new()
var itemData = load(itemsLoad[i])
item.init(itemData, itemData.name) # Pass the item name to init()
# Apply the UI theme to the button

#this next line is where it doesnt work

item.connect(“pressed”,self.__on_item_button_pressed, itemData)

func _on_item_button_pressed(itemData):
var itemName = itemData # Get the item name from the item data
%details_name.text = itemName # Update the label with the item name
func _process(delta):

class_name InventoryItem
extends Button
@export var data: ItemData
func init(d: ItemData, bt: String) → void:
data = d
text = bt

func _ready():

You can use Callable and bind for this:

func _ready() -> void:

func _on_my(txt: String):
	print ("foo ", txt)

So in your case I would guess something like this:

item.pressed.connect(Callable(self, "_on_item_button_pressed").bind(itemData))

For future reference, you can use the “</>”-button above the text-entry field for creating code-blocks that keep the indents. Alternatively put 3 backtick characters before and 3 backtick characters after your code.


Thank you so much!