Jim Brauher wrote:
>
> In the following example program, I would like to make label3 and
> label4 insensitive if 'opt2' were selected from the droplist, and
> sensitive if 'opt3' were selected from the droplist. I tried
> accessing the IDs from the call to cw_form, but I couldn't get those
> IDs until I created an action by pressing 'Cancel' or 'Label'. I
> thought by using these IDs, I could someone do this. Ideas?
>
> Thanks,
> Jim
>
Hi Jim,
Gosh, my second response to a CW_FORM query in 2 days, and I've
never even used the routine!
Try putting your CW_FORM inside a base.
After calling widget_control,base,/real your ids are available.
Text widgets are "type" 3.
Setting the TAG keyword, TAG=options is the key to handling the events.
Hope this helps,
Andrew
PRO test_cwf_event,ev
Common stuff, text_widget_ids
Case ev.tag of
'OPTIONS' : $
Begin
Case ev.value of
'0' : $
Begin
End
'1' : $
Begin
widget_control,text_widget_ids(2),Sensitive=0
widget_control,text_widget_ids(3),Sensitive=0
End
'2' : $
Begin
widget_control,text_widget_ids(2),Sensitive=1
widget_control,text_widget_ids(3),Sensitive=1
End
Else :
End
End
Else :
End
End
;.......................................
PRO test_cwf
Common stuff, text_widget_ids
base = widget_base(/row)
formdesc = ['0, droplist,
opt1|opt2|opt3,label_left=Options:,set_value=0,TAG=options ', $
'0, text, , label_left=label1: , width=15', $
'0, text, , label_left=label2: , width=15', $
'0, text, , label_left=label3: , width=15', $
'0, text, , label_left=label4: , width=15', $
'1, base, , row', $
'0, button, Cancel, quit', $
'0, button, Label, quit']
textform = cw_form(base,formdesc, /column,title = 'Label',IDS=ids)
widget_control,base,/real
print,'Ids = ',ids
text_widget_ids = ids(where(widget_info(ids,/type) eq 3))
print,'text widget ids = ',text_widget_ids
; Insert some text so we can see effect of sensitivity
widget_control,text_widget_ids(2),Set_Value = 'Text 3'
widget_control,text_widget_ids(3),Set_Value = 'Text 4'
Xmanager,'test_cwf',base
End
------------------------------------------------------------ -----------------
Andrew D. Cool
Electromagnetics & Propagation Group
Intelligence, Surveillance & Reconnaissance Division
Defence Science & Technology Organisation
PO Box 1500, Edinburgh
South Australia 5111
Phone : 061 8 8259 5740 Fax : 061 8 8259 6673
Email : andrew.cool@dsto.defence.gov.au
------------------------------------------------------------ -----------------
|