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

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



JD Smith <jdsmith@astro.cornell.edu> writes:

> 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
> endcase
> 
> 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.
> 
> JD

It appears to be the same idea behind this. My MGS_BaseGUI object provides 
an event handler which is appropriate for many things and needs not to be 
touched. So far the objref field in the widget UValue always contains 
"self", and I admit, I am not sure why it should be something else ;-)

Cheers,

Martin

-- 
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[
[[ Dr. Martin Schultz   Max-Planck-Institut fuer Meteorologie    [[
[[                      Bundesstr. 55, 20146 Hamburg             [[
[[                      phone: +49 40 41173-308                  [[
[[                      fax:   +49 40 41173-298                  [[
[[ martin.schultz@dkrz.de                                        [[
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[