Window, Canvas, and Controls

I have a canvas located on a window. Also on the window are two push buttons. The buttons change the position of the canvas on the screen, by changing the .Left value of the canvas. The buttons need to stay in position on the window as the position of the canvas changes.

Everything worked fine until I added a third button to the window. Now the two original buttons stay in place while the canvas moves, but the new button changes position with the canvas. I’ve checked the inspector settings for all three buttons and they’re exactly the same. What am I doing wrong? This is a critical issue for my project.

Is the canvas movement causing your window to resize?

No. The window stays stable. All the action is on the canvas.

That sounds to me like the button has somehow become attached to the canvas.

Try this:

Select the Buttton
Cmd-X to cut it
Make sure that the window is selected and not the canvas
Cmd-V to paste the button back into the window

Sorry, but this didn’t work. I’ve already tried to kill the Button and drag a new one in for the Library, and that also doesn’t work. I’m carefully checking that the Window is selected.

I agree with Tim, it definitely sounds like you are somehow making the Canvas be the parent for this 3rd button. If you click on the Canvas in the Layout Editor and move it, does the button also move? If so, the solution is to not drop the button on top of the Canvas.

Or in the Open event of the Button, you can put code to remove the parent:

Me.Parent = Nil

If none of this works, perhaps you can upload a sample project for people to look at?

Thanks Paul, You solved the problem.

The answer was to make sure the new button was dropped on the window, not the canvas.

I’m converting from VB6 to XOJO and am very happy with the results thus far. This kind of tech support makes me even more enthusiastic. So thanks again.