You didn't show all the code involved (because I don't see any add_child
here) but I see something suspicious:
You are creating a new button at every loop, but you assign it to the same arg
array, (arg[0]
) everytime, so what's in arg[0]
after the while
will always be the last generated button.
arg
will end up be the same for all your buttons because you did create only one before the loop. To fix it I would suggest the following:
var i = 0
while(i <= (options - 1)):
var button = Button.new()
i = i + 1
# Create a new binding at every loop because arguments differ
button.connect("pressed", self, "ButtonPressed", [button, uniqueStuffFromJson])
...