If you create a container control, in the IDE, is the intent that you add methods to the container control as you would a class?
or does one define an interface and have the container control implement it implement it?
@Brian OBrien If you create a container control, in the IDE, is the intent that you add methods to the container control as you would a class?
or does one define an interface and have the container control implement it
Generally speaking, I think when using Container Controls, the design goal is that any controls you place inside a Container should be marked as Private scope, so that nothing outside of the Container can or should be able to access those controls (deliberately or inadvertently).
So if the above is a preferred design goal for your project, then yes, you then want to add Public
Properties to the Container itself to interact with the inner contained Private controls.
An Interface is then useful if you plan in your code design to reuse your Container Control to create more than one variation of your Container. In which case, your interface would generally only implement the "generic" Methods that are useful for each of your control variations, e.g., Methods to "Set" and "Get" data in & out of the Container, or common Events used by each.
With the above in mind, I would build the Container Control first, then once you're satisfied with the functionality, right-click on the Container Control in the IDE and choose "Extract Interface..." to save yourself some steps. This way you get a working Interface quickly, which you can then pair down to the limited common Methods you want to implement on the next Container.
I did this recently with some Containers that I use as views to display a common set of controls, when clicking on specific kinds of records in a Listbox.
@Beatrix Willius You could define an interface. But why?
Note: Strictly speaking an Interface is not required, but is useful for the idea of re-usability. The only down-side to Interfaces in Xojo (at this time) is that Interfaces appear to only support
Methods and not
Properties or Event Definitions. But I usually just add a Note to remind me what I need to add (and why).
I hope that helps to answer your question. Good luck!