Re: Classes and Widget Event Handlers... [message #16225 is a reply to message #16131] |
Mon, 05 July 1999 00:00   |
ronn
Messages: 123 Registered: April 1999
|
Senior Member |
|
|
In article <MPG.11e88590a993852b989810@news.frii.com>,
davidf@dfanning.com (David Fanning) wrote:
> Struan Gray (struan.gray@sljus.lu.se) writes:
>
>> When this was originally posted in June '97, Ronn Kling and Bob
>> Mallozzi pointed out you could exploit the way that IDL calls and
>> defines event handlers. Ronn Kling used the EVENT_PRO keyword when
creating
>> the top level base to define EXAMPLE::EVENT as an event procedure.
>
> I don't recall now if Ronn actually did this or not, but
> if he did it was a BAD idea! Using the EVENT_PRO keyword
> to assign the event handler to the top-level base can result
> in all kinds of havoc. This event handler should *always* be
> assigned with the Event_Handler keyword on the XManager
> routine. (By the way, I am explicitly talking about a
> top-level base that is being *managed* by XManager.)
I actually used event_pro='example::event' in a button definition
statement as I recall. More importantly, this did work in the very
first version of IDL 5.0. But as I remember it disappeared in the 5.0.a
release.
>
>> Both techniques look powerful (and, more importantly, cool :-),
>> but both seem to rely on the ability to invoke an object method as
if
>> it were a normal procedure, something that should, formally, be
>> impossible.
>
> I think it is impossible (or, more accurately, I haven't
> discovered a way to do it). But, by putting the "self"
> structure in the user value of the top-level base, each
> event handler has access to the self object pretty much
> directly.
As of today it is still impossible, but I keep asking RSI to allow us to
be able to specify object methods in the event_pro and event_func
keywords. We can get around it, but it adds just enough obfuscation to
the code that it makes me uncomfortable. Just think if we could do
this... No more non-object event handling code, no more
widget_control,event.top,get_uvalue=state (or self ,etc.). Almost
everything that we write could be objects!
-Ronn
--
Ronn Kling
Ronn Kling Consulting
www.rlkling.com
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
|
|
|