Re: buttons on exclusive base [message #12045] |
Fri, 12 June 1998 00:00 |
David Foster
Messages: 341 Registered: January 1996
|
Senior Member |
|
|
csaute3@alumni.umbc.edu wrote:
>
> I have an exclusive base created by WIDGET_BASE(/EXCLUSIVE).
> (It can only have button children and only one button can be
> set at a time.) I use
>
> WIDGET_CONTROL, button, SET_BUTTON=1
>
> to select one button on in my main routine for my default and
> the rest of the buttons are off.
>
> Question: In my event loop, how do determine which button is
> on? Is there a keyword to WIDGET_INFO?
>
> Or should I create an array with the number of elements equal
> to the number of buttons and the values equal to 1/0 if a
> button is on/off? I don't want to maintain this array every
> time a toggle button is pushed, but if it's the only way ...
>
> Cathy
I believe that if you use CW_BGROUP() to create your exclusive
button group, you can use WIDGET_CONTROL, group_base, get_value=
to get the index of the currently selected button.
Dave
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2240
La Jolla, CA 92037
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
|
|
|
Re: buttons on exclusive base [message #12066 is a reply to message #12045] |
Wed, 10 June 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Cathy (csaute3@alumni.umbc.edu) writes:
> I have an exclusive base created by WIDGET_BASE(/EXCLUSIVE).
> (It can only have button children and only one button can be
> set at a time.) I use
>
> WIDGET_CONTROL, button, SET_BUTTON=1
>
> to select one button on in my main routine for my default and
> the rest of the buttons are off.
>
> Question: In my event loop, how do determine which button is
> on? Is there a keyword to WIDGET_INFO?
The selected button is identified by the ID field of the
event structure in your event handler. All the other buttons
will be de-selected automatically. If you want other parts
of the program to know the currently selected button,
you normally put a "currentButton" field in your info structure.
Your button event handler code might look something like this:
PRO Button_Events, event
Widget_Control, event.top, Get_UValue=infoPtr
(*infoPtr).currentButton = event.ID
END
Cheers,
David
-----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|