Thanks Paul. This is now implemented in main and will be included in the next Studio build: https://feedback.objo.dev/feature/559
I’ve implemented this as opt-in non-visual designer components, rather than treating ordinary classes as fake visual controls.
The workflow is:
- Create a normal Objo class.
- Enable the Available in Visual Designer checkbox for that class.
- This can be done from the class Inspector.
- It can also be toggled from the Navigator context menu.
- The class will then appear in a new Project Components section of the visual designer library.
- Dragging or double-clicking it adds it to the designer shelf, not to the window/container surface.
- At runtime, Studio generates it as a normal property and instantiates it with the layout owner.
For example, a component called MyService dropped onto a window as MyService1 generates code along these lines:
Private Property MyService1 As MyService
MyService1 = New MyService
It does not generate visual-control setup such as position, size, locking, typography, appearance, .Name, or Me.Add(...).
A few details:
- Components are ordinary classes.
- They are not visible at runtime.
- They live on the designer shelf.
- They can expose public writable scalar properties through Studio’s existing Inspector Behaviour system.
- Classes must opt in, otherwise large projects would make the control library too noisy.
- UI subclasses still appear under Project Controls.
- Opted-in plain classes appear under Project Components.
App is excluded.
- Built-in control subclasses are excluded from Project Components.
- Classes must either have no explicit constructor, or have a public parameterless constructor.
- If a component is already placed in a layout and is later opted out, it remains in the layout; it is only removed from the library.
Events are also handled separately from visual controls:
- Built-in control events are not offered for components.
- Project-declared events on the component class, or its inheritance chain, are offered and wired.
So this should support the same broad use case as your Xojo example: a normal non-visual class can be placed on a Window or ContainerControl, configured in the Inspector, and instantiated automatically with the layout.