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

Re: Classes and Widget Event Handlers...

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.)

>     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. True, you have to interact with it through
methods, but for most programs these methods are super
simple to write. Certainly easier, most of the time,
than writing the requisite event handler code.


David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155