# How to call functions from UMG?

**URL:** <https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178>\
**Category:** UI\
**Tags:** unreal-engine, onclicked, UI, Blueprint, question, UMG\
**Created:** [August 16, 2014, 8:58pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178 "2014-08-16T20:58:01Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheTrice](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheTrice](https://forums.unrealengine.com/u/TheTrice)\
**Post date:** [August 16, 2014, 8:58pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/1 "2014-08-16T20:58:01Z")

</div>

So when i used to create buttons using actors , i would just have on clicked event in my level blueprint for this actor , and then i would be able to call all events i need in my game , but using umg i binded one of the buttons to an onclicked event , but in the function blueprint i don’t have any access to any function so what i am supposed to call ? i cant call events from level blueprint nor functions from my actors in the game!? so is there a way to do this ?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_58356e0f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_58356e0f](https://forums.unrealengine.com/u/anonymous_user_58356e0f)\
**Post date:** [August 16, 2014, 10:30pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/2 "2014-08-16T22:30:08Z")

</div>

Call a custom event from inside the click function.

---

<div class="post-metadata">

**Author:** ![TheTrice](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheTrice](https://forums.unrealengine.com/u/TheTrice)\
**Post date:** [August 17, 2014, 2:41am UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/3 "2014-08-17T02:41:01Z")

</div>

Cant since it cant see the custom events of toher blueprints or level blueprint.

---

<div class="post-metadata">

**Author:** ![Bergasms](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bergasms](https://forums.unrealengine.com/u/Bergasms)\
**Post date:** [August 18, 2014, 4:30am UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/4 "2014-08-18T04:30:23Z")

</div>

Hi there, I ran into this same problem and Have figured out how to solve it. Or at least one way of solving it.

- Widget name is TestWidget
- Event dispatched is called closeMenu
- Image gallery is here [on imgur][1]

**Widget Blueprint**

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/4/f/4ff7e1a75f14945cd33f516890fe666a1270c778.png)

**Level Blueprint**

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/3X/9/e/9e2f6af224474909ff49f3f88eb22c7a00b3e32f.png)  
In your widget blueprint, create an event dispatcher as you would any other. I called it closeMenu in mine.

In your level blueprint, or wherever you launch your widget, make sure you get a reference to the menu. It will be a variable of type **UserWidget**

Once you have this reference, you can cast it to your widget, in my case this was called **TestWidget**. Drag off of the ‘as Test Widget C’ anchor and call the ‘Bind Event to closeMenu’ function. Where closeMenu is whatever your dispatcher is called.

Attach a custom event in your level blueprint to the bind event call, and then have that even do whatever it is you want to do. In my case, it just prints out a string saying ‘clicked’

Hope this helps 🙂

---

<div class="post-metadata">

**Author:** ![TheTrice](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TheTrice](https://forums.unrealengine.com/u/TheTrice)\
**Post date:** [August 18, 2014, 1:21pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/5 "2014-08-18T13:21:53Z")

</div>

Worked like a charm , but the problem is I didnt know about Event dispatchers , that will change so much in my game code , why wasn’t this introduced in UE4 tutorials ??

---

<div class="post-metadata">

**Author:** ![Element457](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Element457](https://forums.unrealengine.com/u/Element457)\
**Post date:** [September 8, 2014, 10:42pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/6 "2014-09-08T22:42:36Z")

</div>

I was just wondering the same thing! Great job, Bergasms! Thank you for your help!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10da082a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10da082a](https://forums.unrealengine.com/u/anonymous_user_10da082a)\
**Post date:** [March 25, 2015, 4:18am UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/7 "2015-03-25T04:18:59Z")

</div>

@Bergasms, Can you please help me out here ? In the first image, I understand that ‘Get On Clicked Event’ is a blueprint function that you have created. But can you tell me what the third node with the envelope is ?

---

<div class="post-metadata">

**Author:** ![Bergasms](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bergasms](https://forums.unrealengine.com/u/Bergasms)\
**Post date:** [March 25, 2015, 5:53am UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/8 "2015-03-25T05:53:17Z")

</div>

Heya, Bare in mind that this answer is from a couple versions of UE4 ago, so It might no longer be current.

Off of the top of my head, the node with the envelope is an event dispatcher. You used to be able to create them in your blueprints the same way you create variables and other stuff. An event dispatch is essentially just a message that can be sent out by the owner of the dispatch. So in this case, my **Widget** owns the **closeMenu** dispatch. when i call the dispatch (what is happening in the third node you asked about) the owner is essentially throwing the message out to whoever is listening for it.

In this case, my **Level blueprint** in the second picture is listening. Because the level blueprint created the widget (all the stuff in the second picture before the cast node) it has a reference to it. Once I do the cast node (middle of the second picture) my level blueprint knows that the widget is actually my custom widget called **TestWidget**. It also knows that TestWidget can send out a dispatch message called **closeMenu** so it can bind to that event and catch the dispatch whenever the test widget throws it out.

Hope that makes sense and isn’t too verbose.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10da082a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10da082a](https://forums.unrealengine.com/u/anonymous_user_10da082a)\
**Post date:** [March 25, 2015, 5:57am UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/9 "2015-03-25T05:57:51Z")

</div>

Thanks a lot! That really really helps.! So, is the node below SET the reference to your widget ?

EDIT–  
Also, if you don’t mind can you tell a word or two about the what the last node does in the first image ?

Thanks!

---

<div class="post-metadata">

**Author:** ![RumbleMonk](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RumbleMonk](https://forums.unrealengine.com/u/RumbleMonk)\
**Post date:** [March 25, 2015, 3:56pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/10 "2015-03-25T15:56:57Z")

</div>

The ‘Menu’ is indeed a reference to the widget. As of UE4.5 you don’t need the ‘cast to’ node anymore as the widgets come pre-casted. 🙂

The last node in that first image, the return node, is what is expected in all functions. When you bind a text widget your return node will have a variable of the text data type so that you can plug text right back into it etc.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_10da082a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_10da082a](https://forums.unrealengine.com/u/anonymous_user_10da082a)\
**Post date:** [March 25, 2015, 4:33pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/11 "2015-03-25T16:33:59Z")

</div>

Thanks a RumbleMonk 🙂 I’m new to unreal and I’m trying to figure out things. Really helps!

---

<div class="post-metadata">

**Author:** ![BeastBytes](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BeastBytes](https://forums.unrealengine.com/u/BeastBytes)\
**Post date:** [August 18, 2019, 10:30pm UTC](https://forums.unrealengine.com/t/how-to-call-functions-from-umg/291178/12 "2019-08-18T22:30:41Z")

</div>

Hello,  
How and where did you get that “Menu” node?
