Good day. I created user widget with images and button (let’s call it widget1). I’ve added this widget to another widget (widget2) and I want to call button events in widget2. How can I do it? By default I have only “On Visibility Changed” event.
You can’t call the events of any widget component in blueprint.
Thankfully you can easily create an event that does almost exactly that since button events don’t pass any parameters.
Just add a custom event leading to the same node as the actual click event.
There are other ways of doing the same thing, but this is the way with the least supporting elements.
Unfortunately it doesn’t work for me. I need to get information from widget1 in widget2. For example I want to set widget switcher index with on clicked event. In that case I need to call “On clicked” event of widget1 in widget2 because widget switcher is existing only in widget2. Maybe I need something like override event?
Event Dispatcher. Buttons already have them, you could delegate onClick. Or create a custom dispatcher should you want to send data, like an index value.
set widget switcher index with on clicked event. In that case I need to call “On clicked” event of widget1 in widget2 because widget switcher is existing only in widget2.
- if
widget1
had a button,widget2
could:
- things become significantly more straightforward once you opt for a custom Event Dispatcher instead:
widget1
calls a dispatcher, which is then gracefully caught by widget2
Note how it’s exposed just like the onVisibilityChanged
. Also, when working with UE5 specifically (as opposed to UE4), remember to flag what is needed as isVariable
:
Things are no longer exposed by default.
Thank you. I thought I won’t need it. Seems like I do(
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.