a widget created by the menu anchor?
Not sure what that means but storing references to created widgets will allow you to access and manipulate their data. Getting child/parent is fine but requires casting and can be a tad fiddly since you need to know the expected class.
I want to have multiple menus open at
once so I have no way of telling them
which one is which.
If you are instantiating dynamically, instead of storing widget references in an array (just an index) you can store them in a Map with proper names:
In this case, I’ve created 10 widgets, gave them unique names and pushed them into a Map. I then access the one at index 6 and change its slider value.
You can, of course, make do with just an array but then you’ll need to remember indexes. I still use an index here because it’s a silly example. Assigning unique names as map keys can really help you identify and fetch objects faster. Again, depends on the project’s scope.
Spawning my own widgets is not a problem.
I was using “Menu Anchor” element - it is specifically designed to spawn a widget of a given class when triggered (it has some options to make it easier to specify a relative location of the new widget). So I don’t create a widget by hand - I call “Open” on the Menu Anchor and it spawns its “menu class” widget. There is however no way that I can see to access that new widget.
Is there a way to access a widget created by the menu anchor?
For example, I want to be able to pass some additional data to it after creation.
I can access the class, but not the actual created widget.
Getting child / content / parent doesn’t work.
I know I could use a construct event in the menu blueprint to get the data from a player controller for example, but I want to have multiple menus open at once so I have no way of telling them which one is which.
Forgot that thing existed. Set MenuClass to None and create a widget in the anchor’s binding:
Save it in a reference. This will allow you to access it for as long as it’s valid. The anchor will destroy it when it disappears, though and create a new instance next time.
Variables have an Expose on Spawn flag which will allow you to customise it on creation while the reference can be used to access it afterwards.