Delegates as Parameter
Hello, iam working on a Userinterface in Blueprint and have a hard time dealing with callbacks of buttons etc.
Is there any easy way to supply a delegate reference to a function via a parameter or any way to give my function something so i can bind events in that function?
asked Nov 17 '14 at 01:14 PM in Blueprint Scripting
Yes, but you can't do it using only blueprints: only functions created in C++ can accept delegate parameters. Blueprints can only create event dispatchers, which are multicast delegates.
For UI, you create a dispatcher in your custom widget blueprint. Then when you add that widget component to another widget, you can bind the events directly from the design view, just as you do with the built-in button component: your dispatchers are listed at the bottom of the details panel, with buttons that will create the event nodes for you.
answered Nov 20 '15 at 07:12 PM
You can add delegate parameter to function by dragging event pin from event dispatcher and dropping it on the function.
answered Oct 31 '18 at 08:03 AM
You need to create an event dispatcher as the 'variable' you will store your function in. This is what you will call. Then, in the other class you create a custom event with the same signature you want to be called. get a handle to the first class and find the 'bind to event x' option. then pipe the delegate handle from the custom event into the bind node.
now when you call your function the custom event will be called instead.
answered Dec 26 '14 at 01:12 PM
Asher S Einhorn
Well, there is a way, and it is actually not that difficult. If you have a set list of functions that you are choosing from, and suspect you do, here is the way I would handle it.
You can even use variations on this to bind/unbind events from event dispatchers and such. Up to you.
Follow this question
Once you sign in you will be able to subscribe for any updates here