Re: Top-level bases [message #41063 is a reply to message #41054] |
Thu, 23 September 2004 00:42  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Andrew Rodger writes:
> If I have a pop-up window that was started from within an event
> handler for the primary widget, and I am using the primary widgets
> event function code to handle the events (see below), how do I
> maintain the link to my state data when the pop-up access the event
> function code?
>
> widget_control,'air',tlb,/realize
> xmanager,'air',tlb,event_handler='the same piece of code it is already
> in',/no_block
Typically, we put all the information required to run
our widget program into an info or state structure. Then,
we often pass this structure around in the UValue of the
top-level base. But, in this situation you have *two* top
level bases, although there is a relationship between them:
you called one from the other. So, in principle, you could
pass whatever the second TLB needed from the first when you
call it. That is to say, you could make a copy of the info
structure and pass *that* to the second TLB to store in the
UValue of its TLB.
But now you have two copies of the info structure. Probably
a bad idea.
So, alternatively, you could make one copy of the info
structure, and store a pointer to that info structure in
the UValue of any TLB that required the info structure
information.
That is what I would do in this case. Because a pointer is
very light weight, you can make hundreds of copies and pass
them out like candy. They all point to the same piece of
information. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
|
|
|