'Top Level Only' meaning of Get all widgets of class?

I have a ref ‘optionsMenuRef’ of a widget inside my ‘GameScreen’ widget, when I reload my map this optionsMenuRef still shows the same data as before the reload of the map (OptionsMenu_C_41 or whatever), but I can’t display this optionsMenuRef anymore. I use ‘Set visibility’ to display my OptionsMenu but it doesn’t work after a map reload.

Now although the optionsMenuRef variable still points to the same variable - so it does exist - it won’t show from a ‘Get All Widgets of Class’ call. If I use ‘Top Level Only’ it does return my widget.

How is this meant to work? I guess it’s a garbage collecting issue or something? I am running ‘IsValid’ on my optionsMenuRef which will say it is valid although ‘Get All Widgets of Class’ returns 0 if I don’t use the ‘Top Level Only’ flag… so does this mean IsValid doesn’t work on widgets? Or isn’t reliable?

Thank you.

I believe Top Level Only option returns all the widgets of said class that are visible.

‘Only the widgets that are direct children of the viewport will be returned.’ - that’s the description in the doc… I guess that doesn’t say whether or not that means they are visible or if they are not. I read that as all children that have been assigned/created in the viewport (ie not removed).

I think visible or not does not matter. It would go against how returning actors from a similar function works (unless I’ve missed something) and therefore be ill-advised behaviour, that’s not to say that’s not exactly what’s happening though.

The reason why I’m asking is that my options widget seems to not be able to get re-displayed and I came across this - to me - odd functionality. If I recreate my options widget every time I want to show it it displays fine although sometimes I get two on top of each other. I’m mainly looking to figure out if my understanding of these BP nodes are correct, or if there’s something I’m missing. Thanks for the input, I’ll take a look into what you said!

Old post from the brilliant Rama: ‘Top-Level Only allows you to specify whether my node should only return widgets that are directly connected to the viewport, or whether to return alllll widgets even if they are subwidgets of a viewport widget’.

If a widget is created from inside another widget, is that then considered a subwidget? I’m guessing not, and that subwidgets are widgets embedded into the design/layout of the current widget.