So, firstly, decide how to get a reference of blueprint you want to trigger. Pass as an exposed on spawn variable, get from player pawn/controller or something else. Secondly, create a custom event in main blueprint. Thirdly, in widget create an OnButtonPressed binding, where youâll call a custom event from main blueprint reference.
Create widget in main blueprint and store it in a variable (if you already have a reference to the widget, use that instead).
Create an Event dispatcher in your widget blueprint
Call it when you click the button
In the main blueprint, drag from the widget variable and call bind action to [Event Dispatcher Name]
Drag from the little red square pin in the bind node and create a custom event.
that custom event will get called every time you click the button
(the button text input wonât be there in the custom event, itâs just how itâs setup in the random dispatcher I chose to screenshot!)
Hello, Thank you very much for the reply. Could you let me know please, how to store a whole widget blueprint in a variable?
And also, what if I created widget bleprints not into the main blueprint. Unfortunately I donât know how to create it into the main blueprint. I just clicked on the button (create event) into the widget and it opens me a certain blueprint and it is not the main one.
if youâre creating the widget through blueprints using âCreate widgetâ node, you can right click on the return value pin and promote it to a variable.
OR
if youâre creating the widget using the designer by dragging and dropping, then a variable will be automatically created for you with the same name.
Thank you very much for the reply! Yes it indeed already has a variable, but I canât drag and drop in into another - main blueprint. It says: Cannot place a variable âHouseâ in external scope âEventGraphâ.