# Possible to get button reference when button is clicked?

**URL:** <https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922>\
**Category:** UI\
**Tags:** button, custom-event, reference, unreal-engine, onclicked, question, UMG\
**Created:** [October 11, 2015, 2:30am UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922 "2015-10-11T02:30:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BananasGoMoo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BananasGoMoo](https://forums.unrealengine.com/u/BananasGoMoo)\
**Post date:** [October 11, 2015, 2:30am UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922/1 "2015-10-11T02:30:01Z")

</div>

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.

Any suggestions would be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![Yata](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Yata](https://forums.unrealengine.com/u/Yata)\
**Post date:** [October 11, 2015, 8:09am UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922/2 "2015-10-11T08:09:16Z")

</div>

As far as i know, no. But would be cool to have this feature.

---

<div class="post-metadata">

**Author:** ![Frischer\_Hering](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Frischer\_Hering](https://forums.unrealengine.com/u/Frischer_Hering)\
**Post date:** [October 11, 2015, 8:26am UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922/3 "2015-10-11T08:26:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![BananasGoMoo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BananasGoMoo](https://forums.unrealengine.com/u/BananasGoMoo)\
**Post date:** [October 11, 2015, 5:59pm UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922/4 "2015-10-11T17:59:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![WHSolv](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@WHSolv](https://forums.unrealengine.com/u/WHSolv)\
**Post date:** [June 13, 2017, 3:06am UTC](https://forums.unrealengine.com/t/possible-to-get-button-reference-when-button-is-clicked/334922/5 "2017-06-13T03:06:30Z")

</div>

Look [here](https://answers.unrealengine.com/questions/276531/bind-onclicked-events-to-buttons-created-at-runtim.html).

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](https://answers.unrealengine.com/questions/668694/how-to-pass-self-reference-to-ubuttons-onclicked-d.html).
