Subclass Canvas Control

XOJO 2021r1.1 - Windows 10 Desktop

Am I doing something wrong ?
I insert a new class via the IDE menu.
I give this class a name.
I select as super Canvas in the Inspector.

Result : I have an empty editor window (No Editor) ?
Can not add any controls and or graphics !

Is this normal or what am I missing ?


Did you create an instance of your subclass?

You can’t put controls in a canvas or any other class, controls can be placed only in windows and containers.

Appart from that, when you define a Canvas subclass you need to place an instance of the new class in the window/container, not the subclass itself.

Yes as @Xavier_Mass explains

Drag your subclass from the library onto a Window

1 Like

Windows and containers are “other casses” :man_facepalming:t2:

To edit the class??? :face_with_raised_eyebrow:

That is normal, you can’t “edit” the canvas contents, you are suposed to draw all your content in the paint event but not to add other controls.

If you want other controls inside your custom one, use a ContainerControl, not a Canvas.

Thanks for all the replies.
I had created a Canvas control in a Container Control.
In that canvas I added Three labels that where changing with the mousewheel action.
So my idea was to create a Canvas subclass to have it available in other windows too.
I now understand what I did wrong.
I will switch to a Container Control subclass.


Well, that is actually Wrong too. Xojo is bat to handle overlaped controls and it can lead to poor performance and visual glitches. You should draw the text in the canvas instead of using labels (Or put the labels outside the canvas)