The first control in a Widget Blueprint has no parent.
Have a look at this hierarchy:
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.
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.
the parent of ChildWidget (self) is valid - this is Ok, because the parent is CanvasPanel_6 of the MainWidget. We added it there.
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.
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.
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.
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.
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
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.
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.
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.