I have a custom canvas that has a Paint event. Call it (A).
I subclass that canvas. Call it (B). I want to basically add “some stuff” specifically a Group2D of Object2D’s to the (B) instances. The goal is that when the Paint event occurs it deals with all the issues of the parent (A) and any additional stuff specific to the subclass (B).
How can I make this work? I cannot put a Paint event into (B) because it is a subclass of (A) who has already “claimed” the Paint event.
I have created an Event Definition in (A) and raise that event in the Paint event of (A). That Event Definition is given the parameters of a Paint Event (g As Graphics, areas() As REALbasic.Rect) Then in the subclass (B) I use that event to put in the Group2D group stuff that is unique to (B).
So far this seems to work but I did this reluctantly because now (A) has some special code (RaisingEvent in its Paint code) for the benefit of a subclass that it ideally would not know exists at all. I thought there was some canonical rule that a superclass should not be tasked with worrying about some subclass that might not exist at all in the project.
Is there a more correct or elegant way to accomplish the goal?