Dynamic Menu creation and connecting

Godot Version



I have function that creates menu based on dictionary passed as parameter.
It is working as intended except on a line where I need to connect the button with the metod.
When I explicitly name the method as string it works if I instead use a variable that concatenates a couple of strings and use it instad it doesnt work.

this doesnt work

var buttonName="Continue"
var dicConnect={}
var action = "on_button_"+buttonName+"_pressed"
dicConnect[buttonName] = Callable(self, action)

this works

var buttonName="Continue"
var dicConnect={}
dicConnect[buttonName] = Callable(self, "on_button_Continue_pressed")

I’ve tested this and there is no reason why this shouldn’t work.
Are you posting actual code or a simplified version of it?
I would double check that action = a valid string and that function exists in self.
One thing you can do to test is simply call the callable to see if it is working:

var test = Callable(self, action)    

Obviously you wil have to change the function to remove any parameters (or use test.call(parameters))

Thanks for answering.
Its a bit changed code to be easier to understand but basicly its identical
deo koda

I found it :joy:
the name of the menu button was misspelled by one letter.
Sorry for wasting your time, but you actually helped by saying that it should work and I double checked and found the error.

Thanks again