Working with a lot of OnClicked from widets

So I am working on a MaterialPicker. Which is working fine… However I wanted to have a lot of options so I made 20 options of wooden floors. I typed it out with a lot of copy pasting manually and it works fine. but I am not looking forward to doing it 200 more times…

just for a bit more context here is part of the code I am talking about
basically setting up a event for every button Under the woodflooring tab
(now repeated 20 times)

image
image


is there anyway to do this in a simpler way? I was thinking something like for loops with a Index and setting that to everthing but I don’t think that works? haven’t tried yet because I was a bit worried about possible problems. (This wouldn’t make the code more effective but would atleast save a lot of typing/copy pasting)

Or any other way to not need as many functions? But I don’t see how that would be possible since every button has a sepperate even that needs to run?

EDIT : EDIT: alright found something that works Using the same callback function for many UButtons · ben🌱ui Bind to slate budget widget. which can also give a int when clicked instead ofjust saying i got clicked. I don’t fully understand it yet but its working which is a good first step.

it uses slatecore so you might need to add some things to project to get it to work

1 Like