[4.7.6] [UMG] Chain of Widget-parents broken

Hi!

The first control in a Widget Blueprint has no parent.

Have a look at this hierarchy:

39763-capture_1.png

If you put a widget with this hierarchy into another widget and display it in a hud i would expect the chain of parents to be like this:
Viewport → MainUserWidget → CanvasPanel_0 → ChildUserWidget → Button_136 → Textblock_0

Now check the validity of the parent ( GetParent() node ) of each control and widget.
Everything will be valid except the parents of CanvasPanel_0 and Button_136.
Both are the root controls in their UserWidgets.

I would expect the parent of Button_136 to be ChildUserWidget, but in my case the parent is not set.
This is probably a bug.

Happy hunting!

Hello ,

Thank you for the information provided. However, I would like to ask you for more information regarding the accurate reproduction of this issue. In order to make sure that we are following the same steps, could you provide a more detailed set of steps in order to reproduce this issue on our end. Such information would include the methods that you are using to find the individual parents of the objects that you are testing.

Sure thing. This is going to be a bit longer.

  • Create a new Project - settings do not matter
  • Create a new GameMode and a new Hud, Assign them to your World
  • Create two new UserWidgets: MainWidget and ChildWidget

In Hud:

  • Setup Eventgraph:

In MainWidget:

  • Expose CanvasPanel (In my case its canvas panel 6) as Variable
  • Setup Eventgraph:

In ChildWidget:

  • Expose CanvasPanel (In my case its canvas panel 0) as Variable
  • Setup Eventgraph:

If you play this you will get two Printouts:

  1. the parent of ChildWidget (self) is valid - this is Ok, because the parent is CanvasPanel_6 of the MainWidget. We added it there.

  2. the parent of CanvasPanel_0 is not valid. This is the problem i found. I expected it to be ChildWidget.
    I think, if you get the parent of a lower level control and then the parent of the parent, then its parent and so forth - after a couple of iterations you should end up getting the top level widget. I this case this would be MainWidget.
    The GetParent()-Chain should be complete.

Hello ,

I was able to reproduce the issue you are experiencing on our end. I have written up a report (UE-14292) and I have submitted to the developers for further consideration. I will provide updates with any pertinent information as it becomes available. Thank you for your time and information.

Make it a great day

Parents can only be UPanelWidgets currently, which the UUserWidget is not and likely wont ever be. Might change it in the future though, I’ve considered making GetParent return UWidget instead of UPanelWidget to make these sorts of relationships possible, but I’m afraid of breaking peoples existing code.

Okay, i understand that.
Are there any alternatives for me?

Im trying to build something like radio buttons.
These consist of two parts, first the button widget and second a panel.
The panel sort of takes care of the currently selected value. Each button reports changes up the chain to the panel. This is where my problem with GetParent() comes into play.

The only solution i see is to write a UWidget which contains everything i need and keep track of things myself.

I wouldn’t build radio buttons in that fashion. Radio buttons are just Checkboxes all watching the same value, but for a different condition. I wouldn’t use actual buttons. I would just have each checkbox bound to a different function checking if its state is the current state, and I would have each of their check state change events setup to write their value.

Now if I had to do a TON of radio buttons, I would probably build a new UWidget that automatically generates a set of radio buttons based on a particular UENUM, or maybe a FName Array, something like that.

I have similar problem. I need to track origin of spawned button.

  1. Create bunch of buttons
  2. Each button creates anchored menu
  3. each menu is populated with child buttons. Those buttons needs to know to which anchored menu they belong, so I can close it once button is pressed.

Hope it makes sense :slight_smile:

Any quick workaround ?

GetParent wont work I’m afraid, the buttons are children of their layout panel, but their panel is parented to essentially no-one, because it more or less acts like its own window.

Anyway, we have a global function you can use to close popups generically, just call DismissAllMenus().

Hello tas,

The issue that you have mentioned in your post is unrelated to the original thread. I will need you to create a new thread for this issue for tracking purposes. However, if I understood your question correctly a quick suggestion would be to use the “Get parent” node. If this doesn’t work you can reply with a link to your new thread and I will be happy to take a look.

Make it a great day

exactly, I was relating to GetParent method.

Thanks for DismissAllMenus() ill give it a try. My main concern was, what if I have multiple open menus, then I would want to close only the one associated with button.

Its like having multiple inventories…

Then you’ll have to pass information to the button so it knows who owns it.

would you be so kind and show me example how to do this ?

Im not sure how to pass this information.

As the poster requests, it would be nice to be able to get the parent user widget in some way. It doesn’t have to be GetParent but some way of getting the parent would simplify lots of stuff where you build some logic into a custom widget that wants to communicate with the parent. Seems like it wouldn’t be too hard to add such a thing and would probably help a lot of UI designers. Thanks, -X

Hello Xarol,

The way that you would pass the information to the button is same way that you would for any user widget, you could store some info in a member variable that the button can access when clicked.

I know this is an old topic, but it occurred to me that rather than changing get parent, maybe you could add a “Get Parent User Widget” which could return a reference to the User Widget that holds the base canvas panel.

Technically - if you take any UWidget and call GetOuter that will give you the widget tree, if you call GetOuter on the widget tree, that should give you the userwidget.

Is there any equivalent of GetOuter for blueprints? It appears that GetOuter is not available in blueprints.

Hello Porobic,

I have written up a request (UE-33393) to expose GetOuter to blueprints and I have submitted it to the developers for further consideration. I will provide updates with any pertinent information as it becomes available.

Make it a great day

For anyone who stumbles upon this post, ['s Victory BP plugin] 1 has a node Widget Get Parent Of Class that finds a class by following the parent chain, it also handles the widget chain breaking mentioned in this question using GetOuter.