[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: returning values from widget hierarchy

Vince Hradil (hradilv@yahoo.com) writes:

> First, forgive my ignorance of widget programming ;^)
> How can I return values from a "temporary" widget hierarchy.  That is:
> I have a widget program that creates a new widget for users to adjust
> color settings.  When they select a menu item, I do something like,
> ...build widgets for color settings...
> widget_control, cs_base, /realize
> xmanager, 'color_settings', cs_base
> Then in color_settings_event I handle the various sliders and buttons in
> the cs_base widget.  Then when the user clicks on 'Accept' on the
> cs_base widget, I do widget_control, event.top, /destroy
> What I'd like to do is NOW be able to see what those settings are back
> in the procedure that created the cs_base in the first place.  I would
> like to avoid using COMMON blocks if possible.  I'm familiar with using
> widget_control to store a structure to contain all the information
> needed, but can't seem to figure out how to make it work in this
> instance.

What you need to do is include in your structure a reference
to a pointer, where you will store the information you collect
in the form widget. Then, the function program that calls the form widget
should block the IDL command line. This can be done by making
it a blocking widget or (better) making it a modal widget.
Once the block is released (the block is at the XManager
line), grab the contents of the pointer, free up the
pointer, and return the values you want as the result of
the function.

You can see an example of these kind of modal dialogs by
looking at this program on my web page. This is a program
that is described in a chapter of my book.



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