So I finally got my head around Blueprint communications using event dispatchers (or so I thought), but I’ve hit a snag.
I have a particular custom class of button. When it is created it contains a variable Page_Link. When one of these buttons is pushed, I want it to send that variable to the Level Blueprint, which can then act upon the contents of the variable depending on what it is.
So in the widget designer for the button I have this:
And then in the Level Blueprint, I initially create a widget which contains one of these buttons, and bind the event to the button:
For demonstration purposes, all this does right now is print to the screen the variable it has received. This works fine with one button generated like this.
The problem comes with when I try to dynamically create another button through a function. As soon as I try to collapse the above into a function, the assignment of the event on so forth disappears. It seems I cannot assign an event to a button created through a function…
There must be something wrong in my approach to Blueprint communications here, but I’m new to this so I can’t figure out what.
Just to be clear, this is what I want:
- I want a class of buttons that can be created any number of times, dynamically.
- Each of these buttons contains a (different) variable, specified when it is created.
- When one of these buttons is pushed, it sends the variable name to the Level Blueprint.
- The Level Blueprint then receives this information and acts on it.
What I’m struggling with is the fact that it seems like the assignment (creation of event and binding) seems to be done to a specific button. What I need is a kind of ‘listener’ in the Level Blueprint that just waits for this event to be fired, whatever button it comes from, and receives the variable from the button. It also needs to know what button it came from.
Does that make sense? What is wrong in my approach to this?
Thanks so much for any help.
LS