How to get specific button clicked in a scroll box?

Can you put up your Binding for it?

Might help a little

I’ve finally got a scroll box working properly. In my button BP there is one button with a text block inside a scroll box. I use this blueprint to create a scroll box that has a button with text block for every item in an array of structs, using part of the struct to set the text inside the button.

Now I need to make my buttons work, but since all buttons are created from the blueprint of a single button, how do I reference which button is being clicked? In the button BP I’ve added some basic functionality to the OnClicked, but I need to access the array item associated with the particular button that was clicked. Is there a way I can get what position the clicked button is in the scroll box, then use that to access the correct index in the array?

Thanks for your !

Edit: Added screenshots. Right now the button BP successfully toggles another UMG widget when clicked. But I also need to get the particular struct. that was used to create the clicked button so I can set elements of that Breed widget depending upon which button was clicked.

Is this in the Break Chick Struct at the top or the bottom?

A cleaner way of doing this would be to handle the Text setting in the Button widget itself (the one you are adding to the scroll box). The button widget could have one variable attached to it called ChickenStruct or something. Make sure though, that it is set to public and Expose on spawn is also checked. That way, when you create the widget with the CreateWidget node, it will have an extra input looking for ChickenStruct data. On your button Widget you can have the logic for setting the text. That way each button will have its own ChickenStruct data to access. If you need to ever get back to the parent widget, you can when you use CreateWidget Bind the OnClicked event to a custom event. Example of what I mean below:
ChickenListWidget

ChickenButtonWidget: This is a bound function to get the text for the button itself.

When the button was clicked we call the event dispatcher:

1 Like

Also take note some nodes may look a little different. I quickly made this in a 4.7 preview build but it will work just fine in 4.6.1

This answer hangs here for a long without any single vote. But it should have it! Thank you for this post.

i, too, appreciates the guidance, good sir