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

Re: Object epiphany: A new way of building widget applications

Mark Hadfield wrote:
> From: "Martin Schultz" <martin.schultz@dkrz.de>
> Hi Martin (and idl-pvwave groupies)
> I finally got around to looking at your object widget stuff and I must say I
> am impressed (though I haven't yet grasped all the ins and outs). I like the
> idea of storing an "object reference, method name" structure in each
> widget's UVALUE so that events from that widget can then be translated into
> method calls. Now why didn't I think of that?

Hmm... I had used something like this a few years ago, but instead I
just saved the "action" in the UVALUE, and in the event handling method
I used something like:

widget_control, ev.id, get_uvalue=action
if action eq 'bgroup' then action=ev.value
case action of
      'someaction': self->dosomething, /SOMETHING
       else: call_method,action,self ;all others, just call the method

This is actually fairly nice, since you can add new functionality to the
widget program without ever visiting the event code, but you don't
*require* a method for all trivial events which occur, instead just
catching those which aren't specifically handled and sending them on
their way to special-purpose methods.  Also note how I translate
"actions" on the fly... so for instance a button and a menu item could
trivially perform the same function.  It also pares down the even
handler in size... always a good thing.