OOP general question + for a stackview class

Hi Folks,

I have successfully created a stackview class but I’ve run into an issue
which is chasing me since I’ve learned Xojo and working with controls.

The class contains 2 subclass which are embedded in a specific order.

  • StackViewItem
  • StackViewHeader

Both are Containers as well as the Stackview class and they do communicate via events.

My issue/target to solve:
The StackViewHeader currently has label and disclosure triangle and informs StackViewItem about it’s state (expanded/not) via an action event.
I’d like to have several customized StackViewHeaders with other controls or appearance for instance without creating copies of all base classes
since the StackViewItem and StackView class expects a StackViewHeader and vice versa and subclassing won’t work.

Is there a way to handle that ?

This sounds like the perfect time to use interfaces so that the different classes can be however you want them but all behave exactly the same way, without defining how they must cause such behavior. A brief explanation of the concept is here:

https://en.wikipedia.org/wiki/Interface_(computing)#Software_interfaces_in_object-oriented_languages

Generally I agree but I have no source or example how to do that in my case or at least for Containers.

I have made an exmaple and found a way to handle different header type. You can subclass a containercontrol (Add class and then set to ContainerControl)
This way you can do stuff in ControlA or ControlB but the ControlContainer will handle the events and pass it to the main control.
If there are any thoughts or ideas, please let me know.

https://www.dropbox.com/s/686d1atrzoftrh2/ContainerControlSubclasing.xojo_binary_project?dl=0

[quote=269304:@Rob Egal]I have made an exmaple and found a way to handle different header type. You can subclass a containercontrol (Add class and then set to ContainerControl)
This way you can do stuff in ControlA or ControlB but the ControlContainer will handle the events and pass it to the main control.
If there are any thoughts or ideas, please let me know.

https://www.dropbox.com/s/686d1atrzoftrh2/ContainerControlSubclasing.xojo_binary_project?dl=0[/quote]

hi… the link above does not work

Yeah, the Link is death since years. Here is another implementation.

thanks