[UMG] iterate through canvas elements

I have a Canvas panel widget that already contains objects. I need to iterate through each item in the container. The exact order does not matter as long as I get each contained item as a unique member of the set. The exact type of the returned object does not matter either. For now it has to be a Canvas. How would I use a foreach loop to extract each object? As far as I know a Foreach needs an array input and I’m not able to find out how to get the children of the Canvas in array form. I know as a senior programmer of over 30 years that all containers of multiple objects use either linked lists or arrays (actually a specialized linked list with implicit linking) to store their content. The fact that a Canvas has “Get Child At” and “Get Child Count” is evidence of that. How do I get that array and not just its elements?

Hey. I was curious so I tried to find a solution.
Found a workaround.

Yep. I did consider the issue of using a for loop. I’ve looked at the structure of ForEach and it’s a macro. Guess what it essentially does? It has an implementation of a for loop (I imagine looking at For will give equivalent results). But this exercise revealed a gap in the implementation of UMG. There should be no reason a read-only version of panel contents in array form shouldn’t be available. That’s how C# implements foreach anyways. Good attempt though. You can get the count of children in the panel instead of using a hard-coded value there. If you uncheck the context option in the editor and do a search on foreach you will get a foreach version for editing and for a large list of enums, but nothing for base container classes. I’m guessing you are using the array add as an example of your loop’s use - at least I hope so! Just using your method to pass it to a foreach would be excessive computationally.

Unfortunately there is nothing that allows you to do directly what you want out of the box in blueprints. Since you are a programmer, I suggest that you look into creating your own function to do this in C++, as that should be relatively simple.

Actually it’s demonstrably possible to do in Blueprints. That was the point of this exercise. Unfortunately I wish it were really that simple in C++. You’ve directly seen my UI work in remote view - you know my level of competency. :smiley: (And, yes, the chat is coming along nicely; this is another part of the UI).