38905 - Container Control Parent nil in 10.10.3

OS: OS X 10.10.3

Xojo: Xojo 2015r1

Steps: Up until 10.10.3 it was possible to find out the parent from within a ContainerControl, so it was possible to detect if the Container Control instance was onto another Container Control or onto a Window.

With Yosemite 10.10.3 this is broken. Apparently Parent can only be a control. A rectangle name still shows up fine.

In Windows 8.1 or 10, parent still reports the window or container control fine.

feedback://showreport?report_id=38905

For ContainerControl Parent returns a RectControl, for RectControl Parent returns a Control. If the “parent” is the window it always return Nil. So this is not a bug. Use the Window and the TrueWindow property to get the containing window.

TrueWindow is useless, since it can be several steps higher parent. I need to know what is the container (window or another container control) of the instance of my container control.

Since a ContainerControl acts as a parent, it makes sense that a control on top of it can get it’s type, just as for a Canvas or a Rectangle. In previous versions of OS X as well as in Windows up to 10, me.parent reports EmbeddedWindowControl (note the Control in there). In 10.10.3, it returns nil like a window, and not like a control. That is, I think, exactly the regression bug.

I verified it is not the parent that is broken. It is when a control sits on top of a ContainerControl.

The bug obviously does not come from Xojo, since it works fine in 10.10.2, but from something that has changed with 10.10.3.

Does this work?

Dim parent As Object = Self.Parent If parent Is Nil Then parent = Self.Window End MsgBox(Introspection.GetType(parent).Name)

From the docs ContainerControl is not a Control (despite its name), nor is it a Window

Whether its name says “control” or not really isn’t the determiner of whether its a “control” or not
If it inherits from Control > RectControl etc then its a control at least a UI control
EmbeddedWindowControl doesn’t despite its name

FWIW on 10.9.5 a container reports nil as the parent
Not sure this is new to 10.10.3

[quote=179909:@Eli Ott]Does this work?

Dim parent As Object = Self.Parent If parent Is Nil Then parent = Self.Window End MsgBox(Introspection.GetType(parent).Name)[/quote]

I just realized there was the Window property, and I see your post. Interestingly enough it reports _wrapper_ContainerControl1 instead of EmbeddedWindowControl. But that wil do, since the wrapper distinguishes between a window and a CC.

Thanks.

the wrapper is an implementation detail thats leaked out

You mean it is not documented ? Is it susceptible to change ? I need to be able to know if an instance is within a Container Control in all versions of Xojo, and Mac OS X ideally Snow Leopard up.

The method I was using before worked beautifully until it got broken by 10.10.3. So now if I check for wrapper in the Introspection gettype name of self.window, is it safe ?

Experimenting further, under Snow Leopard and up to 10.10.3 with Self.Window, it is always IsA Window, never EmbeddedWindowControl, whereas when I use Window.Control() it IsA EmbeddedWindowControl.

In Snow Leopard up to 10.10.2, Introspection self.name raises a nil exception for a window, and returns a name for Container Control.

With Introspection Self.Window I get the name of the container/window up to 10.10.2, and in 10.10.3, I get _wrapper_nameoftheCC.

Between all that, I should be able to get by. Now, am I right to be afraid the wrapper leaked out may disappear soon in a future version of Xojo, leaving me with no method to detect a ContainerControl parent unless the bug I reported be fixed ?

Parent for a container control placed directly on a window doesn’t return a reference to the window
Parent returns a rect control which a window isn’t
The sample project you have fails in the exact same way going back to every version I tried

[quote=179963:@Norman Palardy]Parent for a container control placed directly on a window doesn’t return a reference to the window
Parent returns a rect control which a window isn’t
The sample project you have fails in the exact same way going back to every version I tried[/quote]

Oops. Now I redid the project with the test on top of a container itself inside another one, and again, I get Parent Type EmbeddedWindowControl. Must have been real tired. Sorry.