Is it possible to get a reference to a button when it is clicked? for example, I have a bunch of buttons on my UMG UI, and when any of them are clicked, I want to get the object name of the button that was clicked. I have about 30 buttons, so doing 30 separate events in the events graph is sorta unrealistic, especially since they are all essentially the same functions, with the only difference being which object is referenced.
I have tried making an event that I can bind to the OnClicked, but I can’t create a custom one that I can hook up to OnClicked, it just uses its own.
Have you tried making an event dispatcher that takes the button’s reference as input and when a button is pressed it’s bound function fires the event?
Yeah, if I hook up a dispatcher to OnClicked, it won’t let me add any parameters to the custom even that is triggered, because OnClicked has no parameters.
And, with no doubts, you can redefine the native one or create a custom one by making FOnClickEvent_OneParam'ised, making SlateHandleClicked() use OnClicked.Broadcast(this) instead of OnClicked.Broadcast().
Update: don’t forget to override RebuildWidget(), as it uses parent’s SlateHandle-functions. A bit more detailed here.