# Create Reusable Button Widget

**URL:** <https://forums.unrealengine.com/t/create-reusable-button-widget/401854>\
**Category:** UI\
**Tags:** unreal-engine, gui, Widget, question, UMG\
**Created:** [August 11, 2017, 7:25pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854 "2017-08-11T19:25:36Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 11, 2017, 7:25pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/1 "2017-08-11T19:25:36Z")

</div>

I am building a UI using the UMG Editor. I am not sure the art style I will use for my buttons so I would like to create a prefab or a reusable widget that I can use in my various other Widgets for my screens. Then if I later decide I want the font larger or the button a different color I only have to modify it in the one place.

I started by making a widget that contained just a button that had text. This worked fine changing color and fotn on all instances whenever I compiled it. However it failed when I wanted to change the buttons text as there as no way I could do that

How can I create a button prefab/widget that changes will effect all uses.

Thanks!

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 12, 2017, 1:59am UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/2 "2017-08-12T01:59:32Z")

</div>

Hello aspartamed,

You can bind the text component on the button to a variable and change the contents of that variable.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 14, 2017, 12:11pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/3 "2017-08-14T12:11:58Z")

</div>

How? That doesnt allow editing of the text in the UMG as far as I can tell. It requires code or blue print? or am I confused?

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 14, 2017, 12:47pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/4 "2017-08-14T12:47:03Z")

</div>

You need a text variable so create that first. The binding is done in the umg designer. Next to the text box under Content there is a small dropdown menu to the right. Open this and choose the text variable you created. It will now display the contents of the variable instead of the text written in the text box.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 14, 2017, 2:27pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/5 "2017-08-14T14:27:51Z")

</div>

So I created a binding

![193610-binding.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/9/3/3939921d75a81f3c9862c064aafb01dbaabd49ce.png)

Then I create a variable and set it in the bindign like so

 ![193611-event.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/9/f19d87767af9bc34ad03ffdb9cb864947a14e8eb.png)

Then I add the widget to my other UMG widget.  
And edit the property in the editor

![193612-set.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/a/6/2a6c3e01fbabbdff710bb2f1bdbb735cc9bb2511.png)

But I dont see the difference in the editor. And playing I dont see the difference.

Clearly I am missing something. Thanks so much for the help!

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 14, 2017, 5:20pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/6 "2017-08-14T17:20:52Z")

</div>

Are there no difference if you change to contents of the variable?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 14, 2017, 5:30pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/7 "2017-08-14T17:30:19Z")

</div>

correct no difference if I modify the variable. No differences in the editor or at runtime

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 14, 2017, 5:59pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/8 "2017-08-14T17:59:31Z")

</div>

I just have to be sure here. You are changing the value under Default Value in the text variable? If you are right, we are probably looking at a bug in the engine.

![204372-textvar.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/1/b/81bf34b9be9961f86e382372586286e70bbcad62.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 14, 2017, 6:10pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/9 "2017-08-14T18:10:37Z")

</div>

I am changing the variable, in the widget that is using the customButtonWidget I created.

 ![193623-clairfy.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/a/a/7aa0bb3a946b6aefc0e12f1d2527fa76e8d520ee.png)

So I have a widget 2 Widgets

1. CustomButton Widget

2. ButtonUser Widget

CustomButton widget binds the text element of the button to a function, shown above as GetText\_0

I created a variable called Button Text which is the return value of GetText\_0

ButtonUser places multiple CustomButtons on the Canvas. The Button User will reflect any changes made to the CustomButton widget. In the ButtonUser widget clicking on a CustomButton shows the properties, which includes the Default-\>Button Text. Setting that property changes nothing.

I may be confused in one of the steps so I wanted to be clear what exactly I was doing.

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 14, 2017, 6:37pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/10 "2017-08-14T18:37:01Z")

</div>

Ah ha! That makes more sense. I didn’t realize you had several widgets. ☹

I think this is a question wheter you want to change the button in the editor or at runtime. If you drag the CustomButton widget into the ButtonUser widget you can either change the text variable directly in the button or you need to use blueprint to change it at runtime.

The runtime option can be tricky but it all depends on how many button you need. Each button you drag into ButtonUser will have a reference variable that comes along with it. You need to use that reference to access the button variables.

![204373-buttonref.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/2/5/72536aa2d0d110fb4f2bd3d55456a6e680755597.jpeg)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 15, 2017, 7:09pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/11 "2017-08-15T19:09:58Z")

</div>

Ok Yeah I see set it explicitly in the Constructor. This works at runtime, but unfortunately you cannot see the changes at design time. Thanks for the help. I still feel there is a better way out there. I cant be the only one trying to do this.

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 15, 2017, 7:44pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/12 "2017-08-15T19:44:19Z")

</div>

You’re welcome!

Can I ask what you are trying to make or is it secret? 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_8190d78f](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_8190d78f](https://forums.unrealengine.com/u/anonymous_user_8190d78f)\
**Post date:** [August 15, 2017, 7:57pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/13 "2017-08-15T19:57:45Z")

</div>

Eh, I set my button’s text through the constructor as well. The only difference from the above being that I have my “Button Text” exposed as a variable that I can edit in the designer. The changes don’t show at design time, though.

I honestly never thought to try to make it show at design time. It just wasn’t necessary. Generally button width will be consistent, so I set it according to my longest button text and never needed to worry about it.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_08787d181](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_08787d181](https://forums.unrealengine.com/u/anonymous_user_08787d181)\
**Post date:** [August 15, 2017, 8:02pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/14 "2017-08-15T20:02:37Z")

</div>

Not sure yet, Just trying to learn how to build a reusable UI design properly. I couldn’t find good resources on reuse. All the examples I found build it one off.

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 15, 2017, 8:28pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/15 "2017-08-15T20:28:58Z")

</div>

I have never seen tutorials that do that either.

You called this prefab earlier so I guessing you are familiar with Unity? Is this something that is usual there (reusable buttons, I mean) ?

---

<div class="post-metadata">

**Author:** ![Fjellgnu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Fjellgnu](https://forums.unrealengine.com/u/Fjellgnu)\
**Post date:** [August 15, 2017, 8:37pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/16 "2017-08-15T20:37:40Z")

</div>

Yes, that never occured to me either.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_97a946ed](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_97a946ed](https://forums.unrealengine.com/u/anonymous_user_97a946ed)\
**Post date:** [March 1, 2019, 8:17pm UTC](https://forums.unrealengine.com/t/create-reusable-button-widget/401854/17 "2019-03-01T20:17:55Z")

</div>

If you want to see the changes at design time, you need to use the “Event Pre Construct” node
