REALcontrol's Parent property in IDE

I’m developing a plugin based on REALcontrol. The idea is, that the developer using it, can add controls to it in the layout editor by dragging controls from the library to MyControl until the border of MyControl shows a red border indicating that the added control is now a “child” of it.

In the plugin during runtime I’m able to loop over all controls in the window and compare their Parent property with MyControl:

... REALwindow window = REALGetControlWindow(control); long controlCount; REALGetPropValue((REALobject)window, "ControlCount", &controlCount); REALobject (*fp)(REALobject, long) = NULL; fp = (REALobject (*)(REALobject, long))REALLoadObjectMethod((REALobject)window, "Control(index As Integer) As Control"); if (fp) { for (NSUInteger i = 0; i < controlCount; i++) { REALobject subcontrol = fp((REALobject)window, i); REALobject parentControl = NULL; REALGetPropValue(subcontrol, "Parent", &parentControl); if (parentControl == (REALobject)control) { ...

I’m now looking for a way to get the same information in the layout editor at development time, but the code above always returns NULL for the Parent property. I’m getting the subcontrols correctly though. I tried this code in all reasonable functions registered through the REALcontrolBehaviour structure (especially in MyControl_DrawOffscreenFunction(REALcontrolInstance control, REALgraphics graphics)).

[quote=29353:@Lukas Joerg]I’m developing a plugin based on REALcontrol. The idea is, that the developer using it, can add controls to it in the layout editor by dragging controls from the library to MyControl until the border of MyControl shows a red border indicating that the added control is now a “child” of it.

In the plugin during runtime I’m able to loop over all controls in the window and compare their Parent property with MyControl:

... REALwindow window = REALGetControlWindow(control); long controlCount; REALGetPropValue((REALobject)window, "ControlCount", &controlCount); REALobject (*fp)(REALobject, long) = NULL; fp = (REALobject (*)(REALobject, long))REALLoadObjectMethod((REALobject)window, "Control(index As Integer) As Control"); if (fp) { for (NSUInteger i = 0; i < controlCount; i++) { REALobject subcontrol = fp((REALobject)window, i); REALobject parentControl = NULL; REALGetPropValue(subcontrol, "Parent", &parentControl); if (parentControl == (REALobject)control) { ...

I’m now looking for a way to get the same information in the layout editor at development time, but the code above always returns NULL for the Parent property. I’m getting the subcontrols correctly though. I tried this code in all reasonable functions registered through the REALcontrolBehaviour structure (especially in MyControl_DrawOffscreenFunction(REALcontrolInstance control, REALgraphics graphics)).[/quote]

I wouldn’t rely on being able to get the parent or children at design time. The fact that it happens to work now is just an implementation detail / luck.