Control Named 'Window1._wrapper_ContainerControl1'?

https://www.dropbox.com/s/26ydv2opueir4mj/ControlMod.xojo_xml_code?dl=0

So I wrote a method that helps me find finds the parent or window of a control and find the parent or window of that control and so on.

I don’t understand why it returns a RectControl but if I have a control of a certain type, for example called MyType then on the window its called MyType1. When I use the method it will give me a RectControl of a name that’s something like ‘MyWindow._wrapper_MyType1’. The thing that is unusual to me is that it doesn’t have the name ‘MyType1’ and if I use code like this ‘me.ProceedControlHierarchy(1) isa MyType’ then it won’t work.

To give you an idea of the code here is a method from the module:

Function ProceedControlHierarchy(extends value as RectControl, count as integer) As ContainerControlValue
  dim current as new ControlMod.ContainerControlValue
  current.RectControlValue = value
  
  while count > 0
    if current.RectControlValue <> nil and current.RectControlValue.Parent <> nil then
      //RectControl contains the current control
      current.RectControlValue = current.RectControlValue.Parent
    elseif current.RectControlValue <> nil and current.RectControlValue.Window = current.RectControlValue.TrueWindow then
      //reached the window
      current.WindowControlValue = current.RectControlValue.Window
      count = 0
    elseif current.RectControlValue <> nil and current.RectControlValue.Window isa ContainerControl then
      //window is the ContainerControl containing the control
      current.ContainerControlValue = ContainerControl(current.RectControlValue.Window)
    else
      nothing
    end if
    
    count = count - 1
  wend
  
  return current
End Function

There appears to be no documentation on this use of ‘wrapper’ in the name?

Thanks

try using isa EmbeddedWindowControl

But I’m looking for the literal value of MyType1 and that code is not specific enough for the type. I might as well use the Name property but that doesn’t solve my problem. Thanks

A container control on a layout isA Embedded Window Control not a container control
Thats more historical than anything
So that portion of your code is problematic
You should check for ISA EmbeddedWindowControl not ContainerControl

Second the NAME of an instance on a window is just that - JUST a name
You could name it foobar and it would have no other impact than the name changed
ISA MyType would still be true for it

[quote=189807:@Norman Palardy]A container control on a layout isA Embedded Window Control not a container control
Thats more historical than anything
So that portion of your code is problematic
You should check for ISA EmbeddedWindowControl not ContainerControl

Second the NAME of an instance on a window is just that - JUST a name
You could name it foobar and it would have no other impact than the name changed
ISA MyType would still be true for it[/quote]
Well the name is coming up saying ‘wrapper’ within it so the name cannot be the same as the instance on the window. Thanks

I’m getting this kind of name ‘_Window1.Window1’. I cannot solve this issue by the seems of it unless someone gives me some kind of idea of how this works. I have no documentation to work with.

Thanks

if a control has a parent then its parent value will be whatever control is the parent

if it has no parent then the window (or container control) it is on will be the window property of that control

The “issue” you mention suggests you’re looking at the class names which I have no idea why you need to do that

[quote=190702:@Norman Palardy]if a control has a parent then its parent value will be whatever control is the parent

if it has no parent then the window (or container control) it is on will be the window property of that control

The “issue” you mention suggests you’re looking at the class names which I have no idea why you need to do that[/quote]
But the name property is set to the class name? It makes no sense to me that it does that in the debugger. Thanks

What you are seeing is not the container itself, but a placeholder that is created to represent the instance of your container. Containers, being based on Window and not Control, cannot exist in a Control type property, so a placeholder is created for it. Unfortunately, the downside of this approach is that you have no direct access to the container by following either Window.Control() or Control.Parent. Your loop should be something like

// set up
dim p as control
dim c as containercontrol
p = theControl
...
// inside the loop
if p.parent IsA EmbeddedWindowControl
   // can't use parent anymore, so switch to window
   c = p.window
else
   p = p.parent
end

[quote=190727:@Tim Hare]What you are seeing is not the container itself, but a placeholder that is created to represent the instance of your container. Containers, being based on Window and not Control, cannot exist in a Control type property, so a placeholder is created for it. Unfortunately, the downside of this approach is that you have no direct access to the container by following either Window.Control() or Control.Parent. Your loop should be something like

// set up dim p as control dim c as containercontrol p = theControl ... // inside the loop if p.parent IsA EmbeddedWindowControl // can't use parent anymore, so switch to window c = p.window else p = p.parent end [/quote]
Okay, that seems to make sense. So I am basically skipping the placeholders and that is a limitation.

[quote=190727:@Tim Hare]What you are seeing is not the container itself, but a placeholder that is created to represent the instance of your container. Containers, being based on Window and not Control, cannot exist in a Control type property, so a placeholder is created for it. Unfortunately, the downside of this approach is that you have no direct access to the container by following either Window.Control() or Control.Parent. Your loop should be something like

// set up dim p as control dim c as containercontrol p = theControl ... // inside the loop if p.parent IsA EmbeddedWindowControl // can't use parent anymore, so switch to window c = p.window else p = p.parent end [/quote]
Very nice! This seems to work. THANKS