Widget Casting issue object inheritance.

Hi,

So I made a scroll box widget, that widget has a local variable of text. On “Event Construct” a for each loop runs through an array of the local text variable. Then a second widget is created (this widget is a button with text on) the text variable is set (to the array Item) and a child is added to the scroll box object. (This saves me adding and naming the buttons manually and allows me to increase the number of buttons much faster in the future)

This all works fine and displays as it is supposed to, the list box works, the buttons are clickable and they have the correct text on them determined by the items in the array.

This issue I have is I would like each button to do something different when it is pressed, so I can’t make one on clicked event otherwise all the buttons would do the same thing. (as each child is made from the same button) So I am trying a solution where by when the button is pressed it casts to the scroll box (in order to access the local variable array), then as a loop goes through the array I can use the index number and a branch system to determine what should happen from that index number. ( If index 0 add health, if index 1 add mana, ETC)

The issue I have is that when I cast to the scroll box it has no object attached and no object I attach to it allows it to cast, I am told either that it doesn’t inherit from this object and it is rejected or warned that my cast would always fail. I have looked at similar questions on here and tried things such as “get user widget object” “Get all pawns of class” and so on. None of the solutions on here work for my predicament.

So how do I cast to a blueprint widget, when inside another blue print widget? Or how can I set up each button in a list box to do something different.

Thanks

screen shots?

Hey, there isn’t much to screen shot there is a “On clicked” button event attached to a widget cast that wont work because there is no object I can attach to make it to work. All the straight forward ways of casting to the widget do not seem to work.Without the cast I can’t get to the variables stored in the widget locally.

If there is an alternate way to casting to the widget in order to set a button up that is a child event then that would be useful to know as well/instead. I am only casting to the widget because I am at a loss for any other way to do the same thing without it.

Thanks

This is how the list box fills with buttons, I just need to know how to make each button do something different when pressed. I can’t set them up because they are not created until the list box is, so I would need to give them an action after their creation.

I have now solved this issue in a different way. My solution was to create a variable within the Player Controller and then set that variable to the widget I was trying to cast to, I could then access that reference through the player controller and then access the variables within the widget as required.

Thanks