how to get selected entry in scrollbox?

hi everyone
so i am trying to make an inventory list using a scroll box to put all my objects in inventory as a “button” and when i click on it, it displays the proper image, item description on the parent widget. However, i am not sure how i can then use the button on the parent widget to either use or equip based on a bool(not setup yet), but I’m kinda lost on this “how to get selected entry” so then i can Call a custom function inside said item actor class. I looked at all the options from the scrollbox and couldn’t find anything.

anyone has any ideas on how i can do this? Or perhaps a much better way to do this?

thanks

Don’t make entries buttons, make each entry a user widget and then add those to the scrollbox. This way each widget can have its own variables and know what data it holds. You can then dispatch the info to the owning container or any other entity that is interested.

This would also allow you to manipulate those entries dynamically, in case something is added to or removed from the list.

1 Like

sorry i guess i didnt explain it very clearly. Right now each entry in the scroll box is already a user widget (that contains text binded to a variable that i read from the inventory array) - and has a button to be selectable(that’s the only thing the button does right now - be selectable to show the right image and text description onto the parent widget(the one that holds the scrollbox/image/description). I just dont know how to actually do something to them(like remove from parent - and send events to equip or do other stuff from the selected widget) (my idea was to have also a bool if its consumable or not in each one of the inventory items in the array to make visible the equi/use buttom - that i would then use to remove that item/entry from the list and do stuff to it.

It’s a job for an Event Dispatcher:

  • this is a User Widget dispatching a bunch of data when its button is clicked:

  • the parent with the scrollbox can catch those calls:

Any blueprint can catch that call, it’s a matter of hooking it up.


I just dont know how to actually do
something to them(like remove from
parent

Each of those widget can hold (and should!) hold a reference to its own actor. The widget can remove itself from the parent, or the container can remove it. And so can the actor that owns the widget.

One possible way