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

Home » Public Forums » archive » Re: Objects and Widgets
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: Objects and Widgets [message #19932] Tue, 09 May 2000 00:00
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Mark Guagenti (mgenti@evansville.net) writes:

> I am trying to learn how to use objects and widgets together and I have
> ran across a question for all of you. When I am creating a widget button
> such as:
>
> openID = Widget_Button(fileID, Value='Open...', Event_Pro='XPU_RI_Open')
>
> Do I have to make a procedure XPU_RI_Open such as:
>
> PRO XPU_RI_Open, event
> Widget_Control, event.top, Get_UValue=info, /No_Copy
>
> info.obj->open
>
> Widget_Control, event.top, Set_UValue=info, /No_Copy
> END
>
> How come you can't call the object method directly from Event_Pro?

How come pigs is purple and my girlfriends don't love me no more?
It just is, is why.

> I will be using a lot of methods. Will I always have to make a procedures
> to call them?

You will unless you can figure out a way to be clever. :-)

I like to write my event handler "methods" to accept a single
positional parameter--the event structure--just like I write
my event handlers. Then, for every widget that is going to
generate an event in my object widget program, I fill the
user value of the widget with a simple structure containing
the object reference and the event handler method to call.
It looks like this:

openID = Widget_Button(menuID, Value='Open File...', $
UValue={object:self, method:'Open'})
quitID = Widget_Button(menuID, Value='Quit', $
UValue={object:self, method:'Quit'})

All my events go to one giant event handler. (I learned this
from Stein Vidar. :-) And I write the event handler like this:

PRO Handle_All_Events, event
Widget_Control, event.id, Get_UValue=info
Call_Method, info.method, info.object, event
END

Pretty clever, huh? I always use the same event handler, so I never
have to write it over. And my object methods are written essentially
like my event handler procedures. :-)

Cheers,

David
--
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
[Message index]
 
Read Message
Previous Topic: Gauss2DFit question
Next Topic: Re: Expanding IDL's list of approved image formats

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

Current Time: Wed Oct 08 15:10:10 PDT 2025

Total time taken to generate the page: 0.00386 seconds