I have seen this asked in past posts, but have not found a fitting solution.
I am curious as to why there is a function for Get Root Widget in C++ and why this function has not been exposed to blueprints natively?
I am creating a panel/window system, and have base classes for Panel, Header and Controls.
The Panel creates the Header and the Content (Uses Content Class from Variable) and adds them as children to the proper widget in the Panel (Container for Header, Container for Content)
The Panel DOES NOT create the controls, the controls widget is added manually to the Header Class in Editor at time of design of the particular Header. Because the Panel does not create the controls, and the controls are not dynamically created by header, I am having trouble getting the Controls widget a reference to the panel to call panel functions such as Close, Minimize etc.
If the “Get Root Widget” function was exposed to blueprint, I could use that function in the controls base class at On Initialized or On Construct, to get the root widget it is a part of (which would be the Header Widget Blueprint), and that root widget would have a reference to the Panel Widget to be able to call the Panel Functions.
Since this is not exposed, I am at a loss for the best method to achieve the desired result?
I could create a loop to get parent until no parent found? This seems like a terrible idea.
I could implement a Blueprint Interface, but that seems excessive, not to mention not as fast as direct blueprint communication. This would most likely be the only thing the Interface would be used for.
I CANNOT dynamically create the controls widget and add as child, because only the designer at design time would know what widget (container) the controls widget would need to be attached to.
I am at a loss here.
EDIT:
I tried creating a new Base class for the entire Panel System, which contained event dispatchers for Close, Minimize, Collapse etc. The Panel Base, Header Base, and Controls Base classes use the panelsystem base as their parent classes to make sure everything in system has the event dispatchers. I would call the Event Dispatcher in the Controls, but the only way this works, is if I manually bind an event from the controls widget event dispatcher, and then the bound event calls the close panel function on the panel (or whatever function needed). I assume I would not need the new base class, but to just create an event dispatcher on controls base class, and then on each header, manually setup the bind to the Controls Event Dispatcher.
It’s great this works, but would be really nice if this didnt have to be manually setup for each and every control scheme I make for various types of panels and controls etc.
EDIT 2:
I have a panel manager event graph in my Game Instance that is used for tracking panels and reusing panel widgets insted of creating new ones.
I have Collapse, Minimize etc. functions (but not minor functions such as Collapse (which just collapses the content container of the panel, and this function is called directly on panel widget), update a Panel Menu system with the minimized panel references, so that when a button is clicked, the panel will be shown in viewport.
These functions require a Panel Name and Object reference however, to work properly, which I am unable to get when maually placing a Controls Widget into a Header Widget.
Having access to the get root widget would solve all my issues and make this a very easy system to setup. Without it, I feel like I am left making some convoluted solution/work-around unless I make a plugin to expose a single function.
Is there aspecific reason this function is available in C++ natively and not exposed to blueprints? Seems like an easy enough thing to do in any update, but we are on 5.3 now and still not exposed to blueprint when this has been asked for back in 4.16 etc. Which tells me there MUST be some specific reason the devs have not exposed the function to blueprint natively in the engine?