[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object Widgets

David Fanning, davidf@dfanning.com writes

> One of the difficulties with object widgets is handling
> the events that get generated. It is not possible, of
> course, to assign object methods as event handlers,
> so you have to have an event handler that dispatches
> the events to the appropriate methods. 

    I have found that I can have just one such event handler routine
in an ur-widget, which automatically calls the correct event handler
of subclassed widgets.  All my 'real' widgets need is a structure
definition which inherits the ur-widget, an INIT method and an event
handling method.

    I am actually in the process of putting together web pages to
describe the widget and how to effectively subclass other widgets from
it, but as always other things keep getting in the way.  If people
want to look at the code, the following pages has links to the
ur-widget, a minimal widget which actually does something, and shows
how to inherit from and interact with the ur-widget, and a more
complex colour-picker widget.

    I promise, hand on heart, to try and get some explanatory text
written up real soon now.  I'm now using this ur-widget for all my
standalone widgets (I've not started trying to make any compound
widgets with it, though I don't see why it wouldn't work), and love
the way I can add functionality to the ur-widget (see the SHOW method)
which is then immediately available to all my other widgets, including
those up and running on the screen.