# Toggling widget visibility breaks buttons?

**URL:** <https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305>\
**Category:** UI\
**Tags:** button, visibility, unreal-engine, Widget, question\
**Created:** [December 2, 2020, 7:49am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305 "2020-12-02T07:49:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![IEQI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IEQI](https://forums.unrealengine.com/u/IEQI)\
**Post date:** [December 2, 2020, 7:49am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/1 "2020-12-02T07:49:33Z")

</div>

When I make two widgets, each has one button, I create them, add to viewport and when their visibility is toggled (with the Set Visibility node) in game, one of them won’t work after that. Is it a bug or am I misunderstanding something?

---

<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:** [December 2, 2020, 9:14am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/2 "2020-12-02T09:14:50Z")

</div>

> Is it a bug or am I misunderstanding  
> something?

Unlikely to be a bug. Consider showing us the script.

Usually when I hear that only 1 item works out of many (or the other way round), it is caused by incorrect iteration - like _getting all_ and applying it to the incorrect number of elements only.

Again, without you showing us what is up, we can’t help.

---

<div class="post-metadata">

**Author:** ![IEQI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IEQI](https://forums.unrealengine.com/u/IEQI)\
**Post date:** [December 2, 2020, 9:36am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/3 "2020-12-02T09:36:04Z")

</div>

After I toggle visibility I can’t click on the first button any more. The widgets are just two random buttons.

I noticed it on another project but then made as simple setup as I could. I also considered that maybe something else changes when “Set Visibility” node is fired but can’t see what other parameters it could possibly change to somehow disable the other widgets except one. It’s almost like the only widget working is blocking the others or something, but how could it be if I only change visibility?

 ![323648-togglevis.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/8/1e89ec2f00ad72ac752dc07e751e06a293b58e8a.jpeg)

 ![323649-widget-1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/0/f406b000f98f685364c5151e0b4bea79845778db.jpeg)

 ![323650-widget-2.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/6/6/46602e1bb19a5c98097360f98ea04e68ee26d2a5.jpeg)

---

<div class="post-metadata">

**Author:** ![IEQI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IEQI](https://forums.unrealengine.com/u/IEQI)\
**Post date:** [December 2, 2020, 9:40am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/4 "2020-12-02T09:40:32Z")

</div>

And as it turns out, it also breaks one widget when I just do this:

 ![323651-vis.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/9/b/69bf92ec2f0e73b1639e2b03ea1c45111c45cb5b.jpeg)

---

<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:** [December 2, 2020, 10:15am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/5 "2020-12-02T10:15:14Z")

</div>

Makes sense. It’s not a bug, it’s just something to be aware of.

tl;dr:

- **for simple interaction like this, stick with `Not Hit-Testable (Self Only)` for the root, _not_ `Visible`**
- for something more complex, this can be fixed by overriding the `onMouseDown` and passing `Unhandled`.

edit: the `Not Hit-Testable (Self Only)` is the desired flag in many circumstances as you _generally_ do not want to interact with the root of the widget or the canvas the Button is sitting in; you’re interested in the Button, and that is already set to _Visible_.

Hope this makes sense.

* * *

The Long Version:

When you create those widgets, both buttons initially work OK because the root of the widget is set to _Not Hit-Testable (Self Only)_ by default. You then override this setting to _Visible_ thus forcing the widgets to consume ALL input.

When widgets are _Added to Viewport_, they are added in a specific Z-order (you can expand the node and amend it). The higher the Z-order, the more on top the widget is. If both Z-orders are equal (by default), the widget added last gets priority.

When you set them to Visible, the widget added last gets priority and since the root is now _Visible_, it hungrily consumes / blocks interaction to anything that is not itself and does not allow input to reach elements that now _appear_ underneath according to Z-order.

---

<div class="post-metadata">

**Author:** ![IEQI](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@IEQI](https://forums.unrealengine.com/u/IEQI)\
**Post date:** [December 2, 2020, 10:40am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/6 "2020-12-02T10:40:41Z")

</div>

Aah, I see, thank you, that works. I didn’t try that option because the tooltip said that it then cannot interact with a cursor, I thought that meant the entire widget, including all the components inside the widget. But yes, it makes sense to have the “Self Only” and “Self & All Children” options then too.

---

<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:** [December 2, 2020, 10:59am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/7 "2020-12-02T10:59:30Z")

</div>

Having granularity is useful, yes.

I’ll just add that the whole thing is exacerbated by the fact that the widget covers _the entire screen_ - you can’t see it because no element represents it but the cursor can still trace against it.

If you were to set the size:

![323662-screenshot-2020-12-02-105517.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/5/0d5b8be3a2f5c20c28fcaec6efe760dcb9c57c2d.jpeg)

…it would work fine even it was set to Visible. Only the 64x64 would area would block stuff underneath.

---

<div class="post-metadata">

**Author:** ![NikP](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@NikP](https://forums.unrealengine.com/u/NikP)\
**Post date:** [November 8, 2023, 6:58am UTC](https://forums.unrealengine.com/t/toggling-widget-visibility-breaks-buttons/475305/8 "2023-11-08T06:58:38Z")

</div>

Thankyou for bringing the last 2 hours of pulling to an end, Sir!
