Custom Widget OnClicked Event?

Hello,

I have a Custom Widget button, and I would like to have several of it in a menu interface. Kind of like a template for a ready-made button. I have rigged the animations and binded the text as a public variable to allow individual text editing for each of the buttons, however, I am not able to find the Event OnClicked or Event OnPressed or any of those for my custom button. Is there something I’ve done wrong? How can I somehow access an OnClicked Event for each individual button to perform separate functions when clicked?

1 Like

There is a couple of different ways to do this and it is entirely up to you.

Option 1 ) Get a reference to your button template’s button object, and bind in your parent widget.
In the parent widget’s Construct event you can get the reference to your variable and from that drag off a pin for the actual button inside the object. From that button you can drag off another pin and type “assign” or “bind” to bring up the events that are available for binding. Assign does the job of generating a local event for your convenience, bind is useful if you want to create uobject bound functions (both are worth explaining, but you should be able to just assign for now)
The event that is generated will now fire any time you press the button you are binding it from and only that button. You can do this to multiple buttons to have multiple different effects.

Option 2 ) Expose an Event Dispatcher and call that event dispatcher inside your template widget, binding in your parent widget.
This option allows for some more control over general activity inside your template, but also allows you to define unique behavior in roughly the same way as above.
First you would add an Event Dispatcher to your button template, then you would make sure to Call that event dispatcher inside your template on the local button’s Button Clicked event. Now, you should be able to select that template in the parent widget and it should have an interface for your custom event to be added to your parent blueprint in much the same way that buttons currently can.

Hope this helps!
-Spiris

3 Likes

Thanks for the help! I used the Event Dispatcher option so I could learn what they are. It also seems to be a better option in terms of functionality. Appreciate it!

Thanks. Your wording was kind of strange but with a little help from jumping around some seconds of some youtube videos, I found a way to implement your second option. Very helpful. Thanks.

This is a great trick solution 2) thank you!