Re: State of non-exclusive button [message #26383] |
Mon, 03 September 2001 01:11 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
"K. Bowman" wrote:
>
> How do you get the state (checked or unchecked) of a non-exclusive
> (toggle) button?
>
> According to the Reference Guide there is a SET_BUTTON keyword to
> WIDGET_CONTROL, but no GET_BUTTON keyword. The GET_VALUE keyword
> returns the value of the button *label*. I guess that is consistent
> with using WIDGET_BUTTON(id, VALUE = 'Button Label') to create the
> button, but it seems to me to confuse the notions of 'value' and
> 'label'.
>
> Thanks, Ken
I have a compound widget which might help.
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_source/idl_ html/dbase/download/cw_buttons.tar.gz
PRO test_event,ev
WIDGET_CONTROL,ev.id,get_uval=cmd
WIDGET_CONTROL,ev.top,get_uvalue=b
CASE cmd OF
'done':WIDGET_CONTROL,ev.top,/dest
'FF': BEGIN
WIDGET_CONTROL,ev.id,get_value=v
print,v.set
idx=(WHERE(v.set EQ 1,count))[0]
IF count GT 0 THEN BEGIN
value={value:[strtrim(SINDGEN(idx+1),2)],set:MAKE_ARRAY(idx+ 1,/LONG,value=1)}
WIDGET_CONTROL,b,set_value=value
ENDIF
END
ELSE:
ENDCASE
END
PRO test
a=WIDGET_BASE(row=2)
value={value:['MIN','SPEC','DEFAULT','MAX'],set:[1,0,0,0]}
b=cw_buttons(a,value=value,uvalue='FF',row=1,button_xsize=60 ,frame=2,xoffset=0,yoffset=0,button_frame=1)
value={value:['0'],set:[1]}
b=cw_buttons(a,value=value,uvalue='EF',col=2,/nonexclusive,f rame=2,xoffset=20,yoffset=0,button_frame=1)
d=WIDGET_BUTTON(a,val='done',uval='done')
WIDGET_CONTROL,/realize,a,set_uvalue=b
XMANAGER,'test',a
END
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|
|
Re: State of non-exclusive button [message #26390 is a reply to message #26389] |
Fri, 31 August 2001 11:37  |
Steve Hartmann
Messages: 21 Registered: March 2000
|
Junior Member |
|
|
On Fri, 31 Aug 2001 10:55:02 -0500, "K. Bowman"
<k-bowman@null.tamu.edu> wrote:
> How do you get the state (checked or unchecked) of a non-exclusive
> (toggle) button?
>
I would create a button using CW_BGroup, like this:
buttonID = CW_BGroup(parentWidgetID, 'some description', /Col,
/NonExclusive, Set_Value = InitialState)
The " /Col " puts the description text to the right of the toggle
button. "InitialState" is set to "0" or "1" (unchecked or checked).
To determine the current state of the button, use:
Widget_Control, buttonID, Get_Value=CurrentState
Note that, as David suggests, you need to store the buttonID variable
somewhere.
Is this what you were asking for?
-Steve
|
|
|
|
Re: State of non-exclusive button [message #26392 is a reply to message #26391] |
Fri, 31 August 2001 09:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Ken Bowman (k-bowman@null.tamu.edu) writes:
> How do you get the state (checked or unchecked) of a non-exclusive
> (toggle) button?
This is simple. Wrap the non-exclusive base up
in an object widget and call the IS_CHECKED method. :-)
> According to the Reference Guide there is a SET_BUTTON keyword to
> WIDGET_CONTROL, but no GET_BUTTON keyword. The GET_VALUE keyword
> returns the value of the button *label*. I guess that is consistent
> with using WIDGET_BUTTON(id, VALUE = 'Button Label') to create the
> button, but it seems to me to confuse the notions of 'value' and
> 'label'.
I'm telling you. First it's spelling, and now it's
consistency. What do you guys want anyway!? Those of
us who bill by the hour know the value of "confusing
notions", I can tell you. :-)
I think you have to keep track of non-exclusive
buttons the same way you keep track of droplist
values: you have to have some kind of buttonState
variable that you store in some user value that is
easy to get to. Personally, I'd store it in the user
value of the non-exclusive base widget. Then every
button could access it (to change its state) by looking
for it in its parent widget. Or, you could just put
it in the info structure along with everything else
you need to run your program.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|