I've just noticed that Marco Bambini asked this exact same question yesterday. Apologies.
Dave. > From: Dave Addey <[EMAIL PROTECTED]> > Reply-To: REALbasic NUG <[email protected]> > Date: Mon, 24 Apr 2006 09:37:14 +0100 > To: REALbasic NUG <[email protected]> > Conversation: How do I subclass a class with an event? > Subject: How do I subclass a class with an event? > > Hi NUG, > > I have an RB plugin, which has a GetNextDevice function that returns a new > instance of a class, called HIDDevice. A HIDDevice has one event, > DataAvailable. The HIDDevice class is defined in the plugin too. > > What I need to do in RB code is to subclass the HIDDevice class, so that I > can enter some custom code in the subclass DataAvailable event. This is > easy enough. What I also need to do is to assign the output of > GetNextDevice to an instance of my subclass, and this is causing problems. > > For example: > > Dim myHIDDevice as HIDDevice_Mouse // a subclass of HIDDevice > > myHIDDevice_Mouse = GetNextDevice > > > This second line fails on compilation, with the following error: > > Type mismatch error. Expected HIDDevice_Mouse, but got HIDDevice. > > Now, surely, HIDDevice_Mouse is a HIDDevice. So, shouldn¹t this work? > > > I also tried casting the output of GetNextDevice, like this: > > myHIDDevice = HIDDevice_Mouse(GetNextDevice) > > This compiles, but causes an IllegalCastException when this code executes in > the application. I¹m not sure why. > > How should I do this? > > Dave. > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html>
