Question about me.parent = nil

In a window, I put a checkBox. I actually need many of them, so I do a “copy and paste” multiple times to get a whole bunch.

The IDE places each new checkbox about 20 px to the right and 20 px below the “copy” one. Each CMD-C copies the last one produced, so each new one marches across the window. All is well, or so it appears.

But as the pasted checkboxes move down and to the right, they eventually land inside a nearby Label. Now it appears the Label becomes the parent of those new checkboxes, no matter how I move them around. All the other checkboxes belong to the window. I know that in code, I can say “me.parent = nil”, but is there a way to break that link in the IDE? I tried dragging the checkbox out of the Label and that doesn’t seem to work.

My work-around is to delete all those checkboxes that landed on top of another control and manually insert them, a bit of a task if you need 12 checkboxes.

For those superimposed checkboxes that are difficult to drag, you could adjust their coordinates in the inspector, at least to get them to a spot where you can drag them to where you want.

Select the offending control in the Navigator. Hit the Tab key. You’re now on the layout editor, with the control selected. Use keyboard arrows to move it away from the Label. The red square in the layout editor shows the parent of the control.

2 Likes

That’s even better! :slight_smile:

Gavin I will give that a try. It seems like a logical way to solve this. I will report back. Thank you.

In the inspector, you can set the Left value directly and save some arrow key presses.

Right click on the checkbox and select “Unparent item”

7 Likes

That will only move the control, it won’t unparent it.

True, if the checkbox is still over the (unwanted) parent. If it’s no longer over the unwanted parent, you won’t have this menuitem, and moving it with the keyboard arrow keys a pixel to break the parent link is the best solution I’ve ever found.

Tim, thanks. That is exactly what I was looking for.