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

Benoit Minisini gambas at ...1...
Mon Aug 21 18:21:43 CEST 2006


On Saturday 19 August 2006 23:39, Mike Nought wrote:
> Hi all,
>
> I've got a problem:
> I want to create an own version of the ColumnView-class extended by some
> other data-values and stuff. Within this class inheriting ColumnView I want
> to process some Events, the inherited Element raises.
>
> For this purpose i did Object.Attach(ME, ME, "FList") which works well.
> But it is - as far as I tried - not possible to let this class raise it's
> own Events. I tried the following:
>
> EVENT Rename()
>
> [...]
>
> PUBLIC SUB FList_Rename()
> 	[some code]
> 	Object.Detach(ME)
> 	RAISE Rename
> 	Object.Attach(ME, ME, "FList")
> END
>
> Instead of raising the event, nothing happens. Attaching the instance of
> this class in the parent class disables the execution of the
> FList_Rename()-Sub above.
>
> 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,

-- 
Benoit Minisini





More information about the User mailing list