Re: Top-level bases [message #41054] |
Thu, 23 September 2004 17:27 |
algosat
Messages: 7 Registered: September 2004
|
Junior Member |
|
|
>
> 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.
Hi David,
thanks for the advice. I suspected it was going to involve pointers.
I did manage to get around the problem by creating a function
(yesterday) that allows the user to find the widget_id of any realized
widget that is being managed by xmanager. The only input information
needed is the uname of the widget (most of us will always remember the
unames).
I have found that I dont then need to pass any information, regarding
the TLB, to the compound widget (read pop-up). I only need to wait
till I am in the event rountine for my pop-up and use the function to
get the widget id of the widget holding the state info. Update the
info and then return. In this manner it does not matter if I lose a
link, or TLB id, and since the TLB is always realized, I can always
link back to it no matter where I am in the code. If this sounds of
interest to you I can post a copy of the code tomorrow. It was a fix
to a problem that was driving me nuts and where I was hoping I wouldnt
need to use pointers (not that I dont like pointers).
Cheers
Andrew
|
|
|
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
|
|
|