comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Trouble with IDL 5.0.2 (filled contours) unsolved?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Trouble with IDL 5.0.2 (filled contours) unsolved? [message #11045] Thu, 05 March 1998 00:00 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <34FD2406.D7CD49EC@gmx.net>, Reinhold Schaaf <Kakadu42@gmx.net>
writes:

> A third remark concernes event handling: It is not possible to define a
> method of a class as the event handler of a widget. Consider:
>
> PRO CFrame__Define
> struct = { CFrame, $
> wBase:0L, $
> wDraw:0L $
> }
> END
>
> FUNCTION CFrame::Init
> self.wBase = WIDGET_BASE()
> self.wDraw = WIDGET_DRAW(self.wBase)
> WIDGET_CONTROL, self.wBase, EVENT_PRO='CFrame::Event'; Not allowed!
> WIDGET_CONTROL, self.wBase, /REALIZE
> RETURN, 1
> END
>
> PRO CFrame::Event, sEvent
> ;handle events
> END
>
> This leads to the runtime error:
>
> % WIDGET_CONTROL: Object method is not allowed in this context.
>
> As a consequence, one is forced to make the event handler a global
> function. But global functions cannot access members of objects, so one
> has to add methods to the class which would be unnecessary otherwise.

I agree that this is somewhat inconvenient, but the workaround is really pretty
easy. The trick I use is to stick the object itself in the uvalue of the top
level base for this object. There is no need to keep the list of objects.
Here is an example:

;*********************************************************** ******************
pro mca_display_event, event ; event processing for MCA application

widget_control, event.top, get_uvalue = mca_display
mca_display->event, event
end

;*********************************************************** ******************
pro mca_display::event, event ; event processing for MCA application

case event.id of

.... Rest of event processing goes here.


;*********************************************************** ******************
function mca_display::init, font_size=font_size, parent=parent
...
base = self.widgets.base
widget_control, base, set_uvalue=self
xmanager, 'mca_display::init', base, event='mca_display_event', $
cleanup = 'mca_display_cleanup', /no_block
...

____________________________________________________________
Mark Rivers (773) 702-2279 (office)
CARS (773) 702-9951 (secretary)
Univ. of Chicago (773) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars.uchicago.edu (e-mail)

or:
Argonne National Laboratory (630) 252-0422 (office)
Building 434A (630) 252-0405 (lab)
9700 South Cass Avenue (630) 252-1713 (beamline)
Argonne, IL 60439 (630) 252-0443 (FAX)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: NN IDL Freeware
Next Topic: general matrix multiplication

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 14:09:17 PDT 2025

Total time taken to generate the page: 0.80328 seconds