Original post

So, I have a menu type struct that has a slice of buttons. Each button has a variable that I can set to be a function, if I want something to happen when I click the button.

If I make 2 of these, they don’t work. Only the most recently created buttons function.

I’m creating the buttons locally, then referencing them in my function, that I set to the ‘doAction’ variable in the button.

My question is, why would these two separate instances have any effect on one another? I feel like it must be the scope of the variables in the doAction somehow getting shared, but I can’t find a good explanation for it.

submitted by /u/User1539
[link] [comments]