[Gambas-user] Problem implementing events _inside_ a class
Benoit Minisini
gambas at ...1...
Thu Jun 26 02:03:48 CEST 2008
On mardi 24 juin 2008, Patrik Karlsson wrote:
> Hi, since I'm new to Gambas it's a constant struggle, but a nice one that
> is. :)
>
> I'm writng a class, CDiceBoard, that INHERITS Panel.
> Everything went ok until it was time to implement some events for my class.
>
> The following code works, but not the way I want it to be.
> ---
> DIM hDiceBoard2 AS CDiceBoard
> hDiceBoard2 = NEW CDiceBoard(ME) AS "myDiceBoard"
>
> PUBLIC SUB myDiceBoard_MouseDown()
> DEBUG
> END
> ---
>
> How can I put the _MouseDown() inside CDiceBoard.class and make it work?
>
> Regards
The first question is: why do you need to catch MouseDown events inside
CDiceBoard class?
Anyway, events are intended to the final user of an object. If you need to
intercept them inside the implementation of the object class, you have to use
Observers.
An observer is an object that can intercept any event on any object: look the
documentation in the wiki about the Observer class in the gb component.
Regards,
--
Benoit Minisini
More information about the User
mailing list