Remove From Parent does not work on a user created widget

I have a template widget I’m using to easily manage different windows

The template has a single button on it, the close button which I have selected below.

This is my event for the close button

I even tried calling ‘Get Parent’ and then remove from the parent as well. Still no effect

It works when I just create the template widget in game.

But when I make a new widget and add this template widget, I can’t get it to actually remove itself. I stepped through and it’s actually hitting the ‘Remove from Parent’.

What can I do?

I think ive had a similar problem to you. My menu system uses child widgets for the buttons, one of these is “play”. Clicking on play opens another level which is called inside the child widget, but removing the whole menu fails using like what you have above.

My salvation was using Get All Widgets Of Class and a for each loop. This way I could kill all the widgets once the level changed.

Hopefully this might help you

5 Likes

I was wondering about that too,

in the end i did it the other way around and call Remove Child inside the Parent which worked out just fine.

However i have a constant HUDWidget, so i can do whatever i like to its children, because it has all Menus(and menu has submenus stored) and Static HUD Elements.

IMPORTANT: I’m always in this situation. Remove from parent will not work if you Add to viewport 2 or more times by mistake.
So UE4 remove correctly, but a reference is lost and the UE4 will only remove the last one.

So be shure to not add if there is one already there. With this assured, removeFromPArent will work perceftly

7 Likes

thank you so much bro :slight_smile:

The reply was too late, but I faced the same issue. So, I bound the close button function in the parent widget.