Getting controls embedded onto a canvas

I had a window that was getting taller due to adding more and more things into it, so I decided to make it scrollable. The first thing I did, therefore, was to add a canvas to the window, resize it to the window (minus a bit for the scrollbar), and sent it to the back using the layering controls. I then added the event handlers etc to handle the actual scrolling aspects. Various posts here were helpful in that regard.

When I came to test it, however, I found that most of the controls did not move. This was because they were not on the canvas, and no matter what I did with the layering buttons, I couldn’t get these controls to reliably be on the canvas. A couple of controls were properly embedded (why them? Who knows), and they moved as expected with the mousewheel, so that showed that the scrolling aspects were correct.

What I had to do in the end was select all the non-scrolling controls, move them out of the window, de-select them, select them all again, and move them back to where they were. Then all worked as expected.

Is this a limitation of the IDE or is there a better way to get existing controls onto a canvas that is added after the controls are in place?

Did you consider using TabPanel or PagePanel or… ?
(set together related controls and dispose them in a XxxPanel).

Unsure of that: get an eye there .

If it works the way I understand, when you add a control, you can set its parent to ypur Canvas. Once more, I may be wrong.

You have to make sure the controls are children of the canvas for them to scroll correctly. When you drag the control over, you will notice a read outline around the canvas.

But you can also make a control child of the canvas in code in Open, for instance if it is not over the canvas in the IDE

Me.Parent = Canvas1

[quote=360535:@Tim Streater]What I had to do in the end was select all the non-scrolling controls, move them out of the window, de-select them, select them all again, and move them back to where they were. Then all worked as expected.

Is this a limitation of the IDE or is there a better way to get existing controls onto a canvas that is added after the controls are in place?[/quote]
You should have been able to nudge them with the mouse or keyboard to get the parenting to take effect. Personally I usually use the keyboard because it’s easier to control. One pixel up, one pixel down.

Or 8 pixels up, 8 pixels down.

BTW: why 8 pixels and not 10 pixels ?
(I am always have to add 2, 4, 6 or 8 pixels with the keyboard arrow key)

This is only a debugging window for me, so yeah, this does it, ta.

[quote=360567:@Emile Schwarz]Or 8 pixels up, 8 pixels down.

BTW: why 8 pixels and not 10 pixels ?
(I am always have to add 2, 4, 6 or 8 pixels with the keyboard arrow key)[/quote]

You should always do things in multiples of 4 as they scale better with HiDPI.

8 @ 100% = 8
8 @ 125% = 10
8 @ 150% = 12
8 @ 175% = 14
8 @ 200% = 16
8 @ 225% = 18
8 @ 400% = 32

10 @ 100% = 8
10 @ 125% = 12.5
10 @ 150% = 15
10 @ 175% = 17.5
10 @ 200% = 20
10 @ 225% = 22.5
10 @ 400% = 40

Half pixels tend to lead to unwanted anti-aliasing (non-crisp results) to cope with the value being split by landing in between two pixels.