I want to create a new custom class to have a listbox and a search field above the listbox. Is it possible to incorporate a container (Listbox + Search field) in a new class? Or, is there another simple solution to solve this problem?
The Container, with those two controls, is the new class.
Thank you for your answer. If the ContainerControl is a class then I expect it is also possible to make a subclass from a ContainerControl?
Well… that’s tricky. You can’t subclass views, but you can embed them in other containers.
You can make instances of the DesktopContainer, both in the IDE and in code.
Thank you all. I have used Container Controls several times. However, I was not aware that a Container Control is actually a class with limited capabilities (no inheritance).
You can certainly define a superclass of your own making and set its parent to DesktopContainerControl. You can then set the parent of a real Container control to your class. This allows you to share methods, events and properties between your subclasses.
Obviously you can’t have a Container control with an appearance be a superclass of another container control with a different appearance. How would it know what it should look like.
Thank you Ian, your reply makes the use of a Container Control and the relation to Classes and SubClasses very clear to me.
You can split it even further. A superclass of Container with basic functionality, then subclasses of that with more specific functionality. Only then do you add controls to the subclasses with even more specific functionality. It’s the same with the Window class. I think I’ve gone 3 layers deep in subclassing before finalizing the UI.
That would be DesktopContainer now.
To be clear about this technique…
- Put a generic class onto the Navigator
- Set its Super to DesktopContainer
- Add code items that should be shared among containers
- Drag a DesktopContainer from the Library to the Navigator
- Change its Super to the name of the class you created in Step 1.
Thank you for the great ideas. I am working on my new notes and examples for a class on Xojo starting september 2023 at the university. I will try your fantastic ideas to create a new example. I may later share some notes and examples on a website. I keep you and the Xojo community informed.