Adding a User Widget that has another User Widget as parent does not work as expected

  1. Create a new Widget Blueprint called SuperWidget and add some stuff to it, so that it is visible
  2. Create and add to viewport in the level script on BeginPlay
  3. Make sure this works and you see it
  4. Create a new Widget Blueprint called ChildWidget
  5. Go to its class Settings and set the Parent Class to SuperWidget
  6. Enable the Construct event and add a call to the parent Construct event
  7. Change the level script to spawn a ChildWidget
  8. The stuff that was visible inside the parent widget is no longer visible in the child widget.

Hello ,

I was unable to reproduce this issue on our end. However, I was unclear as to some of the steps that you listed above and so I may have had different results. I have a few questions for you that will help narrow things down.

Quick questions:

  1. When you say"Enable the Construct event and add a call to the parent Construct event", could you please how it is that you achieved this step? I used a create widget node and added the super widget to the viewport (this worked as expected).
  2. Can you reproduce this issue in a clean project?
  3. After reproducing this issue in a clean project (if possible) are there any steps that may have been missed in your original post?

Excuse me for my rushed instructions! The problem description is wrong too. The problem is that the content of the parent widget does not show when we add the child widget to the viewport.
My goal is to create child widgets of which I can override parent widget functionality while still being able to see the parent’s content on screen.
I’ll answer your questions in the revised description:

  1. Create a new Blank Blueprint project with Desktop/Console quality and no starter content

  2. Create a new Widget Blueprint called SuperWidget and add a TextBlock to it, so that it shows something on screen when added to viewport.

  3. Create the widget and add it to the viewport in the level script on BeginPlay

  4. Your project now looks similar to this:

  1. Create a new Widget Blueprint called ChildWidget

  2. Open the ChildWidget, go to the Graph tab, click the Class Settings button and set the Parent Class to SuperWidget.

  3. In the Event graph, enable the Construct event by dragging off a wire and adding a random node (like Print String). Then click Compile.

  4. Right click the “Event Construct” node and add a call to parent function.

  5. Delete the “Print String” node and connect the “Parent: Construct” node with the “Event Construct” node and hit Compile and Save.

  6. The ChildWidget’s event graph now looks like this:

  1. Change the level script to spawn a ChildWidget

  2. The textblock that was visible inside the parent widget is no longer visible in the child widget:

Hello ,

After looking over your steps to reproduce this issue. I believe that this is working as intended. The reason that your Super widget is not being added to the screen is because it has not been created and added to the viewport. When the Overrided Event construct is called it is simply going to run the construction script from the parent class. If you would like to add your parent widget to the viewport via the child widget you could could simply use the create widget and add it to the viewport. This will also run the construction script that is inside of the super widget as well as add it to the viewport (a widget construction script is ran when it is added to the viewport) I hope that this information helps.

Make it a great day

Hi Rudy,
This does not adhere to the concept of inheritance and parent classes as is the case with normal Blueprints. Therefore I don’t think this is desired (or useful) behaviour.
By the way, what you are saying is not true. By creating a Child Widget you have also created a SuperWidget and in fact added it to the viewport because the Child Widget IS a Super Widget.
Look, I can create my Child Widget, cast it to a SuperWidget and then add it to the viewport and still see nothing!

Your work around does not help me when we actually start to make use of the power of inheritance.

Suppose that my SuperWidget has a lot of other widgets added to its CanvasPanel and that it performs a lot of animations and has many functions for input handling and many other things.

Now also suppose that I want to make another widget that has all the functionality and appearances of the Super Widget, but I just want to make a tiny change to the way one of the animations is calculated, for example in a function called “GetAnimationPosition” and I want to add some extra functionality that the SuperWidget does not have.
In this case I would expect I could make my child widget as in my previous example and then override the said function and add more content.

Class inheritance is the perfect solution here! I don’t want to make a copy of SuperWidget, because if I then change something later in SuperWidget the changes will not be reflected in the copy!
And I don’t want to add SuperWidget to the CanvasPanel of ChildWidget, because then I can’t override its functionality!

How do you propose I add the contents of the SuperWidget to the screen and reuse its functionality, but also have the overrided functionality in the “GetAnimationPosition” function and the extra content and functionality I put in ChildWidget?

Hello ,

Could you tell me exactly what it is you are trying to do? If I had a better idea of what it was that you were trying to accomplish I may be able to explain things a little more clearly. As for the screen shot that you provided, it is not within the child widget. I was unclear. I meant that you could use the “Create widget” node in side of the child widget.

Example:

In this example I have added the parent widget to the viewport with the construction event of the child. This means that when the child is called to the viewport it will then in turn create the parent.

As for being able to Overrided a function. You would need to add a dummy return (this is due to a known issue) such as a boolean. The function will then appear in the list of overridable functions in the child widget.

As I said I will be able to give a more tailored answer once I have a better understanding of what it is exactly that you would like to do.

Hi Rudy, think of it this way:
Basically I’m trying to do with UMG blueprint widgets what you can already do with regular Blueprints when you right click them and select ‘Create Blueprint based on this’.

Blueprints based on another Blueprint (i.e. with another Blueprint as parent) inherit ALL the parent’s properties and, when freshly created, behave exactly like the parent blueprint. This is useful, because now we can create many different blueprints that have shared functionality, but maintanance on this shared functionality is performed in just one place, namely the ‘parent’ (also referred to as ‘super’) Blueprint. Furthermore the Blueprints derived from a parent (also referred to as ‘children’) can have extra functionality that the parent blueprint does not have. Finally, we could also override or append to some of the shared functions of the parent blueprint inside the child blueprint.

What I expect from a UMG widget that is based off of another widget is that it behaves exactly like its parent, i.e. it shows the content of all its parents on screen when it is added to the viewport. Currently this is not the case; when I spawn a ChildWidget that is based off of SuperWidget, it does NOT behave exactly like its parent, i.e. the contents of SuperWidget are not visible on screen when ChildWidget is added to the viewport. This seems to be a bug, because the inherited components of SuperWidget are present and initialized, but not visible on the screen.

Closer investigation confirms that the inherited components are present and initialized indeed, but can’t be enabled. Here I am creating a ChildWidget that has SuperWidget as parent and that also has an extra textblock added to it:

45170-result.jpg

I’ll continue my answer in the next post, because I have reached the character limit.

Reply continued:

We can access the SuperWidget components inside the ChildWidget by making them variables in the SuperWidget Designer tab. Then I can query their visibility and enabled state like so:

We see that the SuperWidget’s components are initialized in the ChildWidget, but they can’t be enabled. So this is obviously a bug.

I hope that you also understand now that what you show me in your example does not make sense from a programming point of view, since the ChildWidget IS a SuperWidget, meaning that it inherits all the components of the SuperWidget. So you are creating a ChildWidget (thus including all the SuperWidget components it inherited) and then you create an additional SuperWidget that you also add to viewport.
So basically you’re initializing two SuperWidgets of which one also happens to be a ChildWidget. However, due to this bug the SuperWidget components inside the ChildWidget are not brought on screen.

If you have any more questions, please consult one of the programmers of the staff first. I believe that they will recognize the undesired behaviour here.

Hello ,

After speaking with a developer I was able to find out that the type of feature that you are talking about in your post when you say that you would like to be able to right click and create a widget based on this widget is supported currently. This is something that is known to the developers. However, there is a similar functionality that is built in to widget blueprints. Have you tried using “User Created” widgets? These will allow you to reuse other widgets inside of widgets as well as modify them to suit your needs. In your first example instead of re parenting the widget you could have simply dragged a copy of “Super Widget” into “Child widget”. From there you would be able to modify and copy “Super widget” as you see fit. I hope that this information helps.

Make it a great day

Hi Rudy,

What I’ve been trying to explain a number of times now is that dragging in a copy of SuperWidget into the ChildWidget hierarchy has limitations opposed to proper class inheritance. I can’t override functions or events from SuperWidget within ChildWidget. You are again giving me a proposition that has already been discussed, I quote:
“I don’t want to add SuperWidget to the CanvasPanel of ChildWidget, because then I can’t override its functionality!”

The only thing that “create a blueprint based on this” does, is setting the parent class to the Blueprint we are deriving from.
We did this manually in ChildWidget, but still we can’t override functions like with normal blueprints, as explained in my examples.
If blueprint inheritance was working correctly with UMG, this would have been possible, but in the current engine version UMG inheritance is not working to full extent.

I appreciate your time, but it seems you are not familiar with basic object-oriënted programming and I have to keep repeating myself and notice that you are not reading my answers well, or simply lack experience in technical terms to understand them. It costs me a lot of time to keep fabricating extensive examples without any real progress towards acknowledgement or thorough understanding of the issue.

Can you please acknowledge this as a bug or unfinished implementation so that I can agree with your answer? You do not have to provide me with any workarounds, I’m merely pointing out an engine feature that is not working as expected.

Hello ,

I sat down with a programmer and we have written up a report (UE-16764) detailing the issue that was mentioned in your post. It has been sent to the developers for further consideration. I will provide up dates with any pertinent information as it becomes available. Thank you for your information and time.

Make it a great day

Thank you for your time, Rudy. I appreciate it!

Hi !

Is there any status update on this issue ?
I am still experiencing it on UE 4.10.0

Thank you.

Hello Caracole,

I went ahead and double checked on this issue for you. It appears that this issue’s status has not been updated to fixed as of yet. I will be sure to update the community interest for this issue. Thank you for your time and information.

Make it a great day

I think “NativeWidgetHost” exists to solve this problem but it is not working either or I can’t make it work. Currently inheriting from a widget just make it access Super Widget’s variables and functions. I hope this situation will work as soon as possible at least runtime not desigtime.

I would love to be able to Parent a UserWidget and have it show up in the Design View.

Hi Rudy,
is there any news on this? As far as I can see, in 4.11.2 we still don’t have a proper inheritance in UMG.
Thanks

Hello Klawd3,

After taking another look at the report, it appears that this request is still under consideration. However, I will be sure to bump up the community interest on the report for this issue.

Make it a great day

Hi,

This problem still exits in 4.12.5. If there is no chance to resolve the issue, just tell us and we could consider to develop in another way…
regards

Hello RomuVdr,

I have provided a link to the public tracker. Please use the link provided for future updates.

Link: Unreal Engine Issues and Bug Tracker (UE-16764)

Make it a great day