Re: Help with pick menu widget code [message #12891 is a reply to message #12877] |
Tue, 15 September 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Doug Larson (djl@REMOVECAPSloki.srl.caltech.edu) writes:
> I am attempting to make a small program to pop up some menu
> buttons based on a user set resource. I am attaching the
> code to this post in the hopes that someone can tell me
> how to make it exit properly!
>
> My intent was to understand how to handle different
> combinations of widgets in one window. Even after repeated
> readings from "The Book of David" I still can't get this to go.
Whew! For a moment there I thought you were reading my
book, but then I had a look at the code. Since I *ALWAYS*
put the main program unit as the last one in the file, I
can tell it's not my book you are reading. :-)
You are not going to believe this Doug, but the only thing
this program is missing is that you forgot to get the
pointer in your button event handler. :-(
I added this line to the top of the PickFinish_Event
function:
Widget_Control, event.top, Get_UValue=pickPtr
Now it exits almost perfectly. There is one small problem,
however. And that is that you *did* remember to put the
pointer back at the end of the routine with this line:
WIDGET_CONTROL, event.top, SET_UVALUE= pickPtr, /NO_COPY
This piece of code fails now, however, because the action
of the DONE button is to destroy the top-level base. Of
course, you can't stick something into the user value
of a widget that no longer exists.
I might fix this problem like this:
IF Widget_Info(event.top, /Valid_ID) THEN $
WIDGET_CONTROL, event.top, SET_UVALUE= pickPtr, /NO_COPY
But, to tell you the truth, I wouldn't be fooling around with
NO_COPY keywords if what I'm passing around is a pointer. There
really is no point to it. (Pun intended.) A pointer is a two
byte integer. I wouldn't be worrying about getting it with a
NO_COPY and I wouldn't be worrying about putting it back. If you
have the pointer reference, you have the thing itself. There is
nothing whatsoever to copy.
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|