# Showing a widget when clicking a button widget

**URL:** <https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370>\
**Category:** UI\
**Tags:** buttons, unreal-engine, UI, Widget, UE4-27, question\
**Created:** [February 15, 2022, 4:48pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370 "2022-02-15T16:48:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 15, 2022, 4:48pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/1 "2022-02-15T16:48:32Z")

</div>

Hello,

I am having a hard time understanding widgets. My team tasked me to look at UI for our little game we are making. They gave me a task where I have to hide 3 button widgets when pressing another button widget. These button widgets are all a part of one widget called “TestWidget”. The TestWidget is added to the viewport when launching the game. You can see one button in the corner and three buttons next to it. The button in the corner is supposed to hide these three buttons and show them when pressing it again. I am trying to figure out how to do this through blueprints. The corner button widget doesn’t have any logic in itself, but it has a button component. The same goes for the three others. Is there a way how I could make the corner button communicate with the TestWidget to hide and show the three other button widgets according to the input?

If I understood my assignment correctly, I should implement all logic in the TestWidget event graph. That to me, sounds quite tricky, if not impossible. Am I required to put logic into the button component inside the button widget to hide/show other widgets (for instance calling for a custom event inside TestWidget)?

I appreciate all the help, cheers!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 15, 2022, 5:24pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/2 "2022-02-15T17:24:25Z")

</div>

To clarify: we have 2 separate widgets:

- `1st` has 3 buttons and is added to the viewport
- `2nd` is a corner button toggling the visibility of the `1st`

How does the second, corner button end up on the screen?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 15, 2022, 5:36pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/3 "2022-02-15T17:36:00Z")

</div>

Let me rephrase:

We have a TestWidget, which is added to viewport.

The corner button is a component of Test Widget. So are the other three buttons.  
 ![problem](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/1/5/e15b6a7c9ee645c78afcbf7dadbb6739e254b020.png)

Pressing the corner button is supposed to hide the other three.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 15, 2022, 5:42pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/4 "2022-02-15T17:42:37Z")

</div>

Sounds clear. Try this in the Test Widget:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/e/e6eba9cc67232b8c03564817bd9ab3a7a31e4aba.png)

I _assumed_ the corner widget has a button inside. Can be done without a button, too.

* * *

In case this bit is unclear:

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 15, 2022, 5:51pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/5 "2022-02-15T17:51:14Z")

</div>

It did the job perfectly!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 15, 2022, 6:55pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/6 "2022-02-15T18:55:22Z")

</div>

I am now trying to hide the buttons by interacting with anything else but the button. Much like what a lot of mobile games have, for example by having a “Close” button, but instead of pressing that, pressing just anywhere on the screen would hide the pop-up. How could I go about that?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 15, 2022, 6:57pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/7 "2022-02-15T18:57:34Z")

</div>

Try this:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/f/4dfc2c59d271a6a43b679b13f040ac65a0b48e54.png)

* * *

Also, if this is supposed to be a pop-up (you could have lead with that, ha), I’d immediately gravitate towards a Menu Anchor:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/7/a/c7aef767f27eff5a6d367e72c581bde5f7d52de7.png)

But that’s optional, of course. Depends on what other functionality will be needed later on.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 15, 2022, 7:23pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/8 "2022-02-15T19:23:34Z")

</div>

It doesn’t seem to work for me. When I click anywhere else on the screen, the three (now visible) button widgets persist. And I only mentioned pop-ups as reference.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [February 15, 2022, 9:08pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/9 "2022-02-15T21:08:06Z")

</div>

For this the root will need to be set to Focusable:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/b/d/dbdf37a05fe0c4e96f4b9e4ab1cf252a84c9fd42.png)

And you may need to give this widget focus to start with:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/0/4/5049ddb877b83bfe50b82ff3ffb02677c7d29a50.png)

Now clicking on anything else should make those buttons go away.

* * *

There are more ways to achieve that but without knowing the ultimate end goal, it’s somewhat hard to advise. I’d still use the `Menu Anchor` as it stands. We’ll see what else is needed.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_d8824708](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_d8824708](https://forums.unrealengine.com/u/anonymous_user_d8824708)\
**Post date:** [February 16, 2022, 12:44pm UTC](https://forums.unrealengine.com/t/showing-a-widget-when-clicking-a-button-widget/498370/10 "2022-02-16T12:44:52Z")

</div>

This worked, thanks a bunch!
