Signal returning object I cant access

Godot Version

4.2

Question

my code was working in version 3. am trying to return id of button pressed. button created procedurally I set the id.
out put now is [@Button@25:<Button#36758882003>] and am looking for 25

func genButtons():
	for i in numberOfNotesInDisplay:
        modeNotes.append(note.instantiate())
modeNotes[i].setCellNumber(i)
		add_child(modeNotes[i])
modeNotes[i].connect("pressed", _button_pressed.bind([modeNotes[i]]))

func _button_pressed(button):
	var pressedButtonText = button
	print(pressedButtonText)

output is [@Button@25:<Button#36758882003>] in version 3 I used button.text in my function. and 25 was the output.

Is “i” the value that you want and not modeNotes[i]?

no I want the value that nodeNotes[i] contains. the value was added by modeNotes[i].setCellNumber(i).

Then you probably want

modeNotes[i].pressed.connect(_button_pressed.bind(modeNotes[i].getCellNumber()))

or whatever you called the function that gets you the cell number.

1 Like

how could I engage the button with ‘mouse hover over button’ by pressing a ‘w’ key on keyboard

yes this is my button modeNotes[i].???

Sorry, I don’t understand what you’re asking.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.