# UMG Widget 'Event Drilling'

**URL:** <https://forums.unrealengine.com/t/umg-widget-event-drilling/768062>\
**Category:** UI\
**Tags:** event-dispatcher, unreal-engine, Widget, question, UMG\
**Created:** [February 10, 2023, 2:11pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062 "2023-02-10T14:11:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![FelixSab1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FelixSab1](https://forums.unrealengine.com/u/FelixSab1)\
**Post date:** [February 10, 2023, 2:11pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/1 "2023-02-10T14:11:55Z")

</div>

Hey, I am coming from a React background and there we have a situation called “prop drilling”, which describes the process of taking some data and passing it through every component in the tree manually.

I am encountering a similar situation using UMG widgets, where I have a custom button, being several layers of custom UMG components deep, that is dispatching a custom OnClick event. Now I had to create an event dispatcher on every level of the hierarchy so that I could pass that event onto the root component, where the side effects are located at.

Is there a more elegant way to handle custom event dispatchers without introducing side effects in the corresponding widget?

---

<div class="post-metadata">

**Author:** ![MattG\_ZeroFill](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattg_zerofill/32/563889_2.png) [@MattG\_ZeroFill](https://forums.unrealengine.com/u/MattG_ZeroFill)\
**Post date:** [February 10, 2023, 3:48pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/2 "2023-02-10T15:48:01Z")

</div>

You should use the new View-Model for binding data, events to UMG widgets: [UMG Viewmodel | Unreal Engine 5.1 Documentation](https://docs.unrealengine.com/5.1/en-US/umg-viewmodel/)

---

<div class="post-metadata">

**Author:** ![Supremative](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/supremative/32/906564_2.png) [@Supremative](https://forums.unrealengine.com/u/Supremative)\
**Post date:** [February 10, 2023, 4:52pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/3 "2023-02-10T16:52:39Z")

</div>

You could drill a widget tree in the following way:

1. Create BlueprintInterface to send events to desired widgets:  

2. Add the interface to your widgets:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/e/4/3e42cc4ad645bd37dc8e2a9c9729dc87a7e95af6.png)

3. Create a macro library with the following macro:  

4. Use the macro to send events from the bottom widget to every upper widget in the tree that does implement the interface:  

5. Catch event:  

Example:  
Widget Tree:  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/1/1/211d170ac89f6b9ed0c8cf00819ba0e4744ef928.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/8/8/1887219f281db7feaccf04f72567a194a8c792bb.png)

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/a/7/0a762e9d96c4ac7abb8bc0aa78d72c4570a63a69.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/0/d/60d605098b8b9cd28f29528c03b2100a3ca86a25.png)

Runtime:  
 ![Drill](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/4/6843dcb4b176adee00491c667e8a1e05241fdce7.gif)

[My Products](https://www.unrealengine.com/marketplace/en-US/profile/Aleksandr+Sidorov)

---

<div class="post-metadata">

**Author:** ![FelixSab1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FelixSab1](https://forums.unrealengine.com/u/FelixSab1)\
**Post date:** [February 11, 2023, 10:10am UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/4 "2023-02-11T10:10:14Z")

</div>

That looks actually great. Too bad that our project currently is blueprint only and I don’t want to introduce C++ just for viewmodels

---

<div class="post-metadata">

**Author:** ![FelixSab1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@FelixSab1](https://forums.unrealengine.com/u/FelixSab1)\
**Post date:** [February 11, 2023, 10:14am UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/5 "2023-02-11T10:14:05Z")

</div>

Thanks, that looks great! I will implement something similar to that

---

<div class="post-metadata">

**Author:** ![Street\_Mage](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/street_mage/32/568933_2.png) [@Street\_Mage](https://forums.unrealengine.com/u/Street_Mage)\
**Post date:** [February 13, 2023, 3:03pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/6 "2023-02-13T15:03:18Z")

</div>

I’m excited about using view models when they finally come to BPs.

---

<div class="post-metadata">

**Author:** ![MattG\_ZeroFill](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mattg_zerofill/32/563889_2.png) [@MattG\_ZeroFill](https://forums.unrealengine.com/u/MattG_ZeroFill)\
**Post date:** [February 13, 2023, 9:32pm UTC](https://forums.unrealengine.com/t/umg-widget-event-drilling/768062/7 "2023-02-13T21:32:29Z")

</div>

Strong agree, I primarily work in C++ but ViewModels and UI stuff are much easier to work with as BP.
