# removing widget not working

**URL:** <https://forums.unrealengine.com/t/removing-widget-not-working/430647>\
**Category:** UI\
**Tags:** moving, removal, unreal-engine, Widget, question\
**Created:** [July 31, 2018, 2:31pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647 "2018-07-31T14:31:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 2:31pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/1 "2018-07-31T14:31:56Z")

</div>

![249010-unbenannt4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/7/9e7f6f9e19807aae9f281a1b63198c35979cce3c.png)

so im standing infront of a dilema.  
here´s the thing:  
i want to press esc to open the menu without the character moving in the background, then press esc again to close the widget.

i added the button, gave it a loop, A opens the wiget and the mouse, B closes the widget and the mouse (more or less) BUT the character was moving.

soo

i added “set input UI only” and the character stoped moving

but

now i can´t close the widget anymore. i tryed adding “set input game mode only” in case of B.  
but thats not working.

any suggestions?

---

<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:** [July 31, 2018, 2:44pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/2 "2018-07-31T14:44:44Z")

</div>

Do not use _Flip_ and _Input_ nodes for this as you’re blocking the input this way.

Use Esc to open the menu normally but override _OnKeyUp_ in the widget to restore the _Input Mode Game Only_:

 ![249015-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/9/b/79b2fb36c2303112ceafcf90866fcc22084ca5f5.png)

Add the code to remove self from parent here - this will destroy the widget.

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 3:37pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/3 "2018-07-31T15:37:22Z")

</div>

ok i dont´know were to add the code to remove self from parent there.  
im not using unreal engine very long.

this is were im currently at:

i made the esc key open the widget normaly and added your code into the widget blueprint

 ![249022-unbenannt5.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/4/7/84780224b91dc4b1ae2413a038744dde913ca3f3.png)

now since the widget hasnt been destroyed it wont close,  
but the problem that the character is still moving remains again.

for those who dont know how to “override” in the widget blueprint here is a picture, since i had to look that up first:

 ![249024-223174-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/d/35ddb7fccce05a1ddc5afeb4e460abce469bb427.png)

---

<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:** [July 31, 2018, 3:42pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/4 "2018-07-31T15:42:47Z")

</div>

> ok i dont´know were to add the code to  
> remove self from parent there.

Right after _Set Input Mode Game Only_.

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 4:03pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/5 "2018-07-31T16:03:01Z")

</div>

ok ive “set input mode to UI only” back into the level blueprint again and your suggestion is working.  
but. i have to click onto the widget befor it can disapear and my mouse is still visible.  
do you have a solution for this? im guessing this would be a more complext matter to solve at a later state.

Thank you for your support 🙂

---

<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:** [July 31, 2018, 4:26pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/6 "2018-07-31T16:26:03Z")

</div>

Yes, when you _Set Input Game UI Only_, feed the _Game Menu_ widget _Return Value_ reference into _In Widget To Focus_:

 ![249019-untitled.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/5/e/25e57d57048ae0b3826b7aca341f09f4f25ae0c9.png)

You may also need to enable _isFocusable_ flag inside of the _Game Menu_ widget for this to work.

* * *

When it comes to mouse visibility, you can handle it via the controller - _Get Player Controller_ → _Set Show Mouse Cursor_.

Widgets, however, override this setting and force the cursor to appear by default. Each widget controls it separately, though - there is a small hidden tab in the _Behaviour_ panel of each widget. This will allow you to individually control cursor behaviour over every single one of them:

![249020-untitled2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/9/4/b943c30889fb6bf134ac8991160196877d1d9808.png)

Hope this makes sense.

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 5:33pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/7 "2018-07-31T17:33:47Z")

</div>

found it. sadly this did not work. this is what happend:  
the menu was only visible when i held down the ECS button due to “isFocusable”

i still need to click on it in order to cancel it

and the mouse is still there when i set Curser behavior to True no matter if i use none or default.

the problem remains

Edit: wrong panel, but its not working in the right one too.  
Hint: the mouse is invisable untill i open the menu, duno if that helps

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 6:07pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/8 "2018-07-31T18:07:49Z")

</div>

oh this is my bad! i meant: my mouse is stil visible when i have closed the menu. sry for 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:** [July 31, 2018, 6:31pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/9 "2018-07-31T18:31:06Z")

</div>

You’ve marked it as resolved. Does it mean you got it to work the way you need it to?

I’m not sure what you expect from the mouse? You want it hidden in game and show in the menus, right?

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 6:39pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/10 "2018-07-31T18:39:01Z")

</div>

i marked my main question as solved “closing the widget”  
but your solution that solved my main problem, brought up some issues.  
i do not wish to see my mouse in the game. i only wish to see it in the menu.  
i used to have a solution for this. “flip flop”. but that is now gone with your solution.  
i am creating a first person shooter. this should give more sense to the topic.

---

<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:** [July 31, 2018, 6:56pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/11 "2018-07-31T18:56:12Z")

</div>

Makes sense.

In this case I would hide the mouse cursor in the controller. Leave the widgets cursor settings at their default values and then:

- open the menu, show the cursor via player controller; maybe even position it in the centre of the widget for extra fanciness…
- onKeyUp, do the stuff you’re doing and just before removing the widget from the parent, get player controller and hide the cursor again

That should work like a charm. Good luck with the rest!

---

<div class="post-metadata">

**Author:** ![Priogeth](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/priogeth/32/88719_2.png) [@Priogeth](https://forums.unrealengine.com/u/Priogeth)\
**Post date:** [July 31, 2018, 7:37pm UTC](https://forums.unrealengine.com/t/removing-widget-not-working/430647/12 "2018-07-31T19:37:08Z")

</div>

this is my solution since the widget apparently has its own cursor.  
“Widgets have their own cursor control and you get to choose whether to show the cursor or not.”

 ![249050-unbenannt9.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/7/f/67f3be750810665069ed8288f1d9ad95eeee8b73.png)

 ![249051-unbenannt8.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/8/158e44374401bdd8bbb8955a8704a25739263e15.png)

its working now. thank you very much 🙂
