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

Home » Public Forums » archive » Re: Prob with classes, widgets and event handler
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: Prob with classes, widgets and event handler [message #32944 is a reply to message #32943] Tue, 19 November 2002 09:38 Go to previous message
savoie is currently offline  savoie
Messages: 68
Registered: September 1996
Member
Sebastian Loebbert <sebaaihb@peach.zrz.TU-Berlin.DE> writes:

> Hi all,
>
> I try to write a class that contains some widgets. The event handler shall
> only call member functions of that class. To have access to the class, I
> try to put 'self' in the UVALUE of the base widget.
> When I 'GET' the UVALUE inside the event handler, self isn't a valid object.
> I attached a small example class which demonstrates the problem (when
> clicking on the 'dummy'-Button, self->DUMMY_FUN should be called, but the
> reference to self does not work. I tested that program on Win2000 and
> Linux with equal results).
>
> What am I doing wrong there?
> Is there a way to make the event handler a member function of the class?

Don't fear, this is a pretty common mistake. Your init function needs to
return 1 to be a valid object. [Didn't you take out a red pen and underline
that in your IDL Programming Techniques (Second Ed.) :) ]

> ;; init function
> FUNCTION OBJ_WIDGET::INIT
> self.DEBUG = 1
> IF (self.DEBUG GT 0) THEN print, "start: OBJ_WIDGET::INIT"
> res = self->CREATE_GUI()
> IF (self.DEBUG GT 0) THEN print, "done: OBJ_WIDGET::INIT"
return, 1
> END ;; of INIT


That will fix your problem.

But, I think you should take a look at a generic handler for object widgets.

the idea is that you don't have to store and retrieve the self object each
time, but you store a structure in the uvalue.


from a Fanning post...
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&a mp;safe=off&selm=MPG.17b8dc785d0409dc98994f%40news.frii. com
<fanning>

button = Widget_Button(bbase, Value='Quit', $
UVALUE={object:self, method:'Quit'})

All the event handler does is get the user value and dispatch the
event to this method of this object:

PRO EVENTHANDLER, event
Widget_Control, event.id, Get_UValue=cmd
Call_Method, cmd.object, cmd.method, event
END

</fanning>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Opensource ASCII data merging/management?
Next Topic: Re: CAT, DOG, 1.7 AND FISH IN IDL - SUPPLEMENTAL

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

Current Time: Fri Oct 10 23:05:59 PDT 2025

Total time taken to generate the page: 1.03468 seconds