MenuAnchor - Get Widgets of Menu Class

Hi,
I was wondering if there was any way to get the Widgets that are contained in a UserWidget that is opened via a MenuAnchor from another UserWidget.

So say for example, I have a Main Menu and when i press a “Quit Game” Button, another Userwidget opens via MenuAnchor. In this new UserWidget there’s two Buttons with “yes” and “no”.
Now what I want is to have a reference to those two buttons in my Main Menu.

I’ve tried it via MenuAnchor->MenuClass->GetDefaultObject<UUserWidget>()->WidgetTree, but the Widgettree is empty, I guess because it’s a class reference and not an object reference?

I’ve also tried iterating through MenuAnchor->MenuClass->Children, which gives me the Buttons and all other widgets, however only as UFields, and I do not know how to cast them to UWidgets again, or get them as UWidgets.

Is there a “fix” to my two approaches? Or is there maybe a whole another way?
Help would be very much appreciated :slight_smile:

is there no way?

Yes, by default object version of WidgetTree would be empty.

Have you looked at using GetWidgetFromName()?

Otherwise, what is stopping you from using Blueprints to handle this?

Alternatively, send a reference to the MenuAnchor to the other UserWidget.
Get it to create the Yes & No options, then add them as children ot the MenuAnchor reference, and keep a reference to the Yes/No options.

I do something similar to this, but using Blueprints.
Same MenuAnchor - different content depending on which user widget I want to use it.

hey thanks for the GetWidgetFromName() tip