Red box around 2 stacked contols

I can’t find any info on this and I know I’ve learned this once.

If I place 2 or more controls on top of each other a red box appears around them. What’s that mean? Does it just mean they share the same dimensions? Obviously if they are all visible and enabled then the top one in the stack hides the others.

Is there a way to control the enabling and visibility of this “stack” of controls so that only one is visible based on some condition?

Thanks.

The control with the red box OWNS the other controls (ie. becomes their parent)… Normally you only do this for groupbox, pagepanel and other “container” types… but it also shows where you might have controls overlapping that really shouldn’t be.

if you want two controls to occupy the same space (but visible only one at a time)… What I do is place one control where you want it to be, then the other one somewhere else… Then in the OPEN event of the 2nd control, I have it set its own postion based on the position of the 1st control and toggle their VISIBLE property as required

Thank you for the explanation. And I’ll implement your suggested solution.

Or place the 2nd control away from the 1st control, then move the 2nd using the Left and Top positions in the inspector into the same position as the 1st control. The two controls do not snap/group/embed together but they are at the same coordinates.

Or, in the control’s Open event, use:

me.parent = nil

Which makes the control’s parent the Window that it is placed on, not whatever control it is sitting on top of in the IDE.

https://documentation.xojo.com/index.php/RectControl.Parent

That’s cool! I think that’s the answer I like.

Note that setting parent to nil is only possible in Desktop. if you ever develop for iOS, you will have to resort to the other techniques, since Parent there is read only.