Project Control that is not a subclass of Timer, Thread, Canvas

In Xojo, if you make a subclass of certain classes, they become a “Project Control” which you can then drag & drop an instance onto a window.

If you subclass something like a Thread or Timer , you get a Project Control that is not visible - it has no width or height and shows up below the window in the IDE, but you can still add Event Handlers to it.

If you subclass a Canvas or Rectangle, you get you a Project Control that has a UI, and can be given a location and size on the Window as well as handling events.

My Question: is there a way to create my own Project Control class which doesn’t have a UI, and is not a subclass of one of the existing no-UI classes such as (Timer, Thread, IPCSocket…)?

You can make just class Class1

And drag it onto the Window then it will appear bellow the Window just like Thread and Timer.

1 Like

You mean with no Super ?

Yes just class inheriting from normal Object will work.

Great info, thanks!

  1. Having a class with no Super works - with the caveat that this class will not show up in the IDE/Library. This means if you are viewing your Window with the padlock icon:

there is no obvious way to drag & drop the Class onto the window.

If you expand the browser so you can see your entire project, then you can drag & drop your class onto the window, and it shows up at the bottom like other controls do:

  1. I am unable to create a class with super of Object. The IDE rejects it and clears it after I type it. Am I missing something?

  2. The IDE/Project Library has a naked “Class” object, but when I drag it to my window nothing happens.

(I’m using Xojo 2019R1.1 today, so there may be IDE bugs).

I have a number of such classes but I always instantiate them in code.

But they don’t seem to show up as project items.

I wonder, could we use Inspector Behavior to somehow tell the IDE that our class should be included in the Project Controls section of the Library?

That is one way of doing it, but I find that it’s much more awkward, as compared to having a single class instance on the window with its own event handlers…

I literally never add custom classes to window with the Library because of all the classes that fill that section up from plugins. I always drag / drop the class from the Navigator to the Window.

The documentation for Object says:

Object is the base class of all other classes.

Your class already is an Object. To see this in action, this code compiles:

dim o as Object = new MyClass
1 Like

The hierarchy is

Object → DesktopControl → DesktopUIControl

If you make a class whose superclass is a DesktopUIControl, it will show up in the library and will occupy a rectangle in the window real estate when dragged there, and have a basic set of properties and events you can use.

If you make a class whose superclass is a DesktopControl, it will NOT show up in the library (but should, as a non-visible one) and will NOT occupy space in the window real estate when dragged there, but will get the events Opening() and Closing() you can use.

If you keep super blank, it will inherit from Object. The most basic Runtime class. Usually not designed to be used as a Control.

1 Like

Nice summary, @Rick_Araujo , thanks.

1 Like

Thanks, @Rick_Araujo – I did some more testing with modern Xojo and here’s what I see:

  • A class with no superclass set in the IDE is a subclass of type Object. If you try to set ‘Object’ as the superclass, the IDE clears it out without any explanation. This is confusing and has been submitted as:
  • An Object subclass never shows up in the Library, but you can drag & Drop from the navigator to a Window, where it shows up at the bottom.
  • A class with superclass of DesktopControl also does not show up in Library, but also has events of Opening, Closing, (and for some reason CreatePane). I submitted a FR to have this show up in the Library:
  • A class with superclass of DesktopUIControl does show up in the Library (under the Project Controls) section, and can be dragged onto a window where it gets a location and size as well as the whole suite of events.

Edit: submitted the bug with CreatePane as as it appears to be an API2 version of a bug that was fixed in API1 ( )

1 Like