How to traverse DesktopContainer

In the new version, when I create multiple DesktopContainers and reference them in Windows1.
I hope to enumerate all Container1 objects. In the past, I could use the following code

for each itm as DesktopControl in self.Controls
MessageBox(itm.Name)
next
Because all controls are subclasses of DesktopControl.
But now it seems that something has changed. DesktopContainer is no longer a subclass of DesktopControl. How can I enumerate it?

This worked in older Xojo, does it not work now (with appropriate “desktop” prefixing)?

Public Function ContainerControls(extends w as Window) As ContainerControl()

  dim theList() as ContainerControl
  dim o as Runtime.ObjectIterator = Runtime.IterateObjects
  
  while o.MoveNext
    if o.Current isA ContainerControl and ContainerControl(o.Current).Window is w  then
      theList.Append ContainerControl(o.Current)
    end if
  wend
  
  Return theList
End Function

I think you have to check that:

myControl IsA DesktopUIControl or myControl IsA DesktopContainer

myControl is an Object.

1 Like

Instead of scanning through all the controls, why don’t you simply keep a list of them for future reference as you are creating and embedding them?

1 Like