I subclassed a Canvas control and named it MyCanvas. In this subclass I added mouse down/up events. In the mouse up event I call a method I added named DoClick. This works fine when I put an instance of MyCanvas in the Window. Now, I subclass the MyCanvas as CustomMyCanvas. I add a method named DoClick to this CustomMyCanvas subclass. I put an instance of the CustomMyCanvas on the Window. When I click on the CustomMyCanvas, the DoClick method for it’s Super, MyCanvas, is executed. Not the method for the CustomMyCanvas subclass. There is a simple demo of this at: http://allmytrash.com/XOJO/TestSubclass.zip. What am I doing wrong??
I thought subclass methods overloaded superclass methods if they were the same name. i.e. subclass methods were used in place of the superclass methods. Maybe this doesn’t work when subclassing built in Controls
I just ran across this on page 141 of the XOJO users guide - Fundamentals under the topic of Polymorphism.
“First, create a new class called Animal. Add to it a Speak method
that returns a String.
Now create a subclass of Animal, called Cat. Add to it a Speak
method that returns a String. This means you are overloading the
unimplemented Speak method on Animal.”
So it seems the folks at XOJO consider a method in a subclass taking precedence over a superclass method is called overloading.