[Gambas-user] How to process Events of an inherited class?

Benoit Minisini gambas at ...1...
Mon Aug 21 21:09:49 CEST 2006


On Monday 21 August 2006 20:13, mike-nought at ...17... wrote:
> Am Montag, 21. August 2006 18:21 schrieb Benoit Minisini:
> > On Saturday 19 August 2006 23:39, Mike Nought wrote:
> > > [...]
> > > How can I process an Event of the inherited class as well as raising
> > > own events at the same time?
> >
> > This is not possible.
> >
> > To do what you want, you have to use composition instead of inheritance,
> > i.e. create your own MyColumnView control class by inheriting
> > UserControl, and by including a ColumnView inside. The MyColumnView
> > control will receive all events raised by the inner ColumnView.
> >
> > Then you have to declare all ColumnView events in MyColumnView, and raise
> > a MyColumnView event for each catched ColumnView event.
> >
> > This is very heavy to do, but I didn't find a better solution at the
> > moment!
> >
> > Regards,
>
> Too bad it doesn't work the way I tried. This would have been far easier.
> Well okay, it should not really be a problem to code as you suggested, but
> it is simply more work.
> By the way, why is it not possible to do something like
> "Object.Attach(SUPER, ME, "FList") for example (Object.Attach(ME, ME,
> "FList") has rather been a workaround)? 

Because SUPER and ME are exactly the same object.

> I don't know how these inheritances 
> are working internally but isn't there an instance of the inherited class
> merged with the inheriting one? Shouldn't you be able to catch those events
> seperately then? 

Alas no. The difficulty comes from the fact that an object can have one and 
only one event observer.

> Might be that I am completely wrong now :D, you considered 
> this probably yourself as well.
>
> Okay, thank you so far. My project is far from being finished yet, so most
> likely I will return with some more questions... Probably about some
> network-related stuff, only tried around with the gb.net-component once.
>
> Oh, one question comes to my mind right now: You are using many so-called
> virtual classes in several other classes in Gambas. I asume there is no way
> to create own ones within a Gambas-project, right? 

Right. Virtual classes are a hack reserved to components written in C/C++.

> I wouldn't need them 
> right now, but it is always good to know something more about the language
> you are currently coding in ;)
> And coding in Gambas is fun!
>
> Regards,
> Franz
>

Regards,

-- 
Benoit Minisini





More information about the User mailing list