Get parent name of a button _on button_pressed()

Godot Version



My root of buttons looks like that:
VBox → HBox → VBox (name in dict) → Label (displayed name), Button (yes), Button (no).
I created many VBoxes with names as keys in dictionary. I connected every Button on the same signal (_on_yes_pressed and _on_no_pressed).

  if key == "Button(yes)".get_parent().name: 
    dict[key] += 1.

The problem is Button(yes) has not been declared, I have no clue how signal should know which button is pressed.The buttons don’t carry any individual significance, so I don’t wanna attach script to each one. I just need a way to get_parent().name of the pressed button in the main script.

Sry I am an idiot. Instead of trying to get path, I should have added dict key into signal additional argument (String). NodePath for some reason did not behave.

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