# Is there a way to get the string name of button pressed?

**URL:** <https://forums.unrealengine.com/t/is-there-a-way-to-get-the-string-name-of-button-pressed/1645136>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [January 27, 2024, 12:02am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-get-the-string-name-of-button-pressed/1645136 "2024-01-27T00:02:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChaosCatGG](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chaoscatgg/32/769776_2.png) [@ChaosCatGG](https://forums.unrealengine.com/u/ChaosCatGG)\
**Post date:** [January 27, 2024, 12:02am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-get-the-string-name-of-button-pressed/1645136/1 "2024-01-27T00:02:28Z")

</div>

If I have button named “button1234” and another button named “button5678” for example, is there a way to get the name of the button pressed?

Pseudocode of what I mean:

button1234.InteractedWithEvent.Subscribe(HandleMyButton)  
button4567.InteractedWithEvent.Subscribe(HandleMyButton)

HandleMyButton(Agent: agent):  
#get string of the button pressed to get to this function like  
#Agent.buttonStringOrOtherwayToGetInfoAboutWhopressedme  
if(button1234):  
Print(“Foo”)  
if(button4567):  
Print(“Bar”)

---

<div class="post-metadata">

**Author:** ![x.why.z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@x.why.z](https://forums.unrealengine.com/u/x.why.z)\
**Post date:** [January 31, 2024, 2:53pm UTC](https://forums.unrealengine.com/t/is-there-a-way-to-get-the-string-name-of-button-pressed/1645136/2 "2024-01-31T14:53:05Z")

</div>

I was looking for a solution to this issue today also and came across this post. I was sad to see it didn’t have an answer, however I was just watching some YouTube videos and came across the perfect solution.

There is a wrapper code for the Subscribe function that allows you to pass variables.

So you can have:

Button1.InteractedWithEvent.SubscribeAgent(OnButtonPressed,”Button1”)

Button2.InteractedWithEvent.SubscribeAgent(OnButtonPressed,”Button2”)

And you’ll be able to access “Button1” and “Button2” in your function.

There is a snippet of code you need to add to your file first, but you might as well just watch this video which explains it all. Start from 1:30

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/7/5475ac8a824ab90004f12abe8ee983f36016776f.jpeg "USE THIS! To Subscribe To Events With Verse In UEFN") ](https://www.youtube.com/watch?v=v30hvvCVTCs)

Hope this helps!

---

<div class="post-metadata">

**Author:** ![ChaosCatGG](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chaoscatgg/32/769776_2.png) [@ChaosCatGG](https://forums.unrealengine.com/u/ChaosCatGG)\
**Post date:** [February 2, 2024, 1:34am UTC](https://forums.unrealengine.com/t/is-there-a-way-to-get-the-string-name-of-button-pressed/1645136/3 "2024-02-02T01:34:33Z")

</div>

This is extremely helpful thanks! Exactly what I needed 🙂 smile:
