|
|
|
|
Re: pulldown menu with multiple selections - Yes we can! [message #17554 is a reply to message #17538] |
Fri, 29 October 1999 00:00   |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Michael Asten (masten@mail.earth.monash.edu.au) writes:
>> Does anybody know how to make a pulldown menu with multiple selections?
>
> I did it using the pull down menu generated by the idl5.2 GuiBuilder,
> with subsequent addition to code to extract the "multiple" selection.
> Attached is a demo example - the task is to select multiple 'loops'
> from the left column of a widget, and single 'line' and 'component'
> from 2nd and 3rd columns of the widget.
Uh, thanks for this, Michael. But I don't see a pull-down
menu anywhere. I see lots of lists. :-)
While I'm not sure your post sheds much light on the
original question, it does, however, nicely illustrate
some previous points I made about the code generated
by the Widget Builder. :-)
Cheers,
David
--
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
|
|
|
Re: pulldown menu with multiple selections - Yes we can! [message #17558 is a reply to message #17538] |
Fri, 29 October 1999 00:00   |
Michael Asten
Messages: 53 Registered: March 1999
|
Member |
|
|
pei zeng wrote:
> Hi, Guys
>
> Does anybody know how to make a pulldown menu with multiple selections?
>
> Thanks!
>
> pei
I did it using the pull down menu generated by the idl5.2 GuiBuilder,
with
subsequent addition to code to extract the "multiple" selection.
Attached is a demo example - the task is to select multiple 'loops'
from
the left column of a widget, and single 'line' and 'component' from 2nd
and
3rd columns of the widget.
On win95/98/NT systems, multiple menu item selection is by the windows
convention of pressing <control> rightMouseClick to select individual
items
additively, or pressing <shift> rightMouseClick to select all menu items
between two highlighted items. I assume Mac and Unix have mouse
conventions for equivalent processes.
I acknowledge the help of RSI Tech support in getting this multiple menu
item selection working - it is not well documented in the idl5.2 online
help.
Regards,
Michael Asten
Code follows:
;
; IDL Widget Interface Procedures. This Code is automatically
; generated and should not be modified.
;
; Generated on: 12/10/98 13:43.49
;
PRO WID_BASE_0_event, anEvent
common
select_subs,loop_index,line_index,comp_index,freq_index,gain _index
_widID_ = anEvent.top
CASE anEvent.id OF
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_LIST_3'): BEGIN
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_LIST' then $
Freq_index= anEvent.index
END
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_LIST_4'): BEGIN
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_LIST' then $
Gain_index= anEvent.index
END
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_LIST_1'): BEGIN
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_LIST' then $
Line_index= anEvent.index
END
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_LIST_2'): BEGIN
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_LIST' then $
Comp_index= anEvent.index
END
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_LIST_0'): BEGIN
; PROCESSING OF LIST SELECTION FOR LEFT COLUMN,
; WHERE MULTIPLE SELECTION REQUIRED
; need a second call to widget_info, to save name of wid
wid = widget_info(_widID_, FIND_BY_UNAME='WID_LIST_0')
; wid now contains the widget id of WID_LIST_0
print,'wid = ', wid
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_LIST' then begin
;now get the indices of the selected list items
; this is a scalar, if only 1 choice made
; this is an array if multiple choices selected
loop_index=widget_info(wid,/list_select)
;print,'anEvent.index=',anEvent.index
;loop_index= anEvent.index
print,'loop_index from multiple select=',loop_index
endif
END
WIDGET_INFO(_widID_, FIND_BY_UNAME='WID_BUTTON_0'): BEGIN
if TAG_NAMES(anEvent, /STRUCTURE_NAME) EQ 'WIDGET_BUTTON' then $
widget_control,anEvent.top,/destroy
END
ELSE:
ENDCASE
END
PRO WID_BASE_0, GROUP_LEADER=_VWBGroup_, _EXTRA=_VWBExtra_
,loops,lines,comps,freqs,gains
;delete this - not neede for simple demo program
;RESOLVE_ROUTINE, 'select_subset2_eventcb' ; Load event callback
routines
WID_BASE_0 = WIDGET_BASE( GROUP_LEADER=_VWBGroup_, $
UNAME='WID_BASE_0' ,SCR_XSIZE=491 ,SCR_YSIZE=175 ,TITLE='IDL' $
,SPACE=3 ,XPAD=3 ,YPAD=3)
WID_LIST_2 = WIDGET_LIST(WID_BASE_0, UNAME='WID_LIST_2' $
,XOFFSET=180 ,YOFFSET=43 ,SCR_XSIZE=57 ,SCR_YSIZE=78,value=comps)
WID_LIST_3 = WIDGET_LIST(WID_BASE_0, UNAME='WID_LIST_3' $
,XOFFSET=254 ,YOFFSET=43 ,SCR_XSIZE=57 ,SCR_YSIZE=78,value=freqs)
WID_LIST_4 = WIDGET_LIST(WID_BASE_0, UNAME='WID_LIST_4' $
,XOFFSET=337 ,YOFFSET=43 ,SCR_XSIZE=57 ,SCR_YSIZE=78,value=gains)
WID_LABEL_0 = WIDGET_LABEL(WID_BASE_0, UNAME='WID_LABEL_0' $
,XOFFSET=38 ,YOFFSET=20 ,/ALIGN_LEFT ,VALUE='LOOP')
WID_LABEL_4 = WIDGET_LABEL(WID_BASE_0, UNAME='WID_LABEL_4' $
,XOFFSET=365 ,YOFFSET=20 ,SCR_XSIZE=28 ,SCR_YSIZE=18 $
,/ALIGN_LEFT ,VALUE='GAIN')
WID_LABEL_3 = WIDGET_LABEL(WID_BASE_0, UNAME='WID_LABEL_3' $
,XOFFSET=276 ,YOFFSET=20 ,/ALIGN_LEFT ,VALUE='FREQ')
WID_LABEL_1 = WIDGET_LABEL(WID_BASE_0, UNAME='WID_LABEL_1' $
,XOFFSET=100 ,YOFFSET=20 ,SCR_XSIZE=62 ,SCR_YSIZE=18 $
,/ALIGN_LEFT ,VALUE='LINE/HOLE')
WID_LIST_1 = WIDGET_LIST(WID_BASE_0, UNAME='WID_LIST_1' $
,XOFFSET=103 ,YOFFSET=43 ,SCR_XSIZE=57 ,SCR_YSIZE=78,value=lines)
WID_LABEL_2 = WIDGET_LABEL(WID_BASE_0, UNAME='WID_LABEL_2' $
,XOFFSET=205 ,YOFFSET=20 ,/ALIGN_LEFT ,VALUE='COMPNT')
WID_BUTTON_0 = WIDGET_BUTTON(WID_BASE_0, UNAME='WID_BUTTON_0' $
,XOFFSET=418 ,YOFFSET=43 ,/ALIGN_CENTER ,VALUE='APPLY')
WID_LIST_0 = WIDGET_LIST(WID_BASE_0, UNAME='WID_LIST_0' ,XOFFSET=18 $
,YOFFSET=44 ,SCR_XSIZE=43 ,SCR_YSIZE=78 ,/multiple,value=loops)
WIDGET_CONTROL, /REALIZE, WID_BASE_0
XMANAGER, 'WID_BASE_0', WID_BASE_0
END
;
; Empty stub procedure used for autoloading.
;
PRO select_subset2, GROUP_LEADER=_VWBGroup_, _EXTRA=_VWBExtra_
,loops,lines,comps,freqs,gains
WID_BASE_0, GROUP_LEADER=_VWBGroup_, _EXTRA=_VWBExtra_
,loops,lines,comps,freqs,gains
END
; MAIN PROG
common
select_subs,loop_index,line_index,comp_index,freq_index,gain _index
loops=['loop1','loop2','loop3','loop4','loop5']
lines=['line1','line2']
comps=['Z']
freqs=['P6.25']
gains=['0']
loop_index=0 & line_index=0 & comp_index=0 & freq_index=0 & gain_index=0
select_subset2 ,loops,lines,comps,freqs,gains
print,loop_index,line_index,comp_index,freq_index,gain_index
end
|
|
|
Re: pulldown menu with multiple selections - Yes we can! [message #17595 is a reply to message #17558] |
Tue, 02 November 1999 00:00   |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Michael Asten wrote:
> pei zeng wrote:
>
>> Hi, Guys
>>
>> Does anybody know how to make a pulldown menu with multiple selections?
>>
>> Thanks!
>>
>> pei
>
> I did it using the pull down menu generated by the idl5.2 GuiBuilder,
> with
> subsequent addition to code to extract the "multiple" selection.
> Attached is a demo example - the task is to select multiple 'loops'
> from
> the left column of a widget, and single 'line' and 'component' from 2nd
> and
> 3rd columns of the widget.
Dear Michael,
this is a bit more modern code of your widget.
The arrangement of the widget was done by the GUI Builder too. An important
difference to your code is
thats the ids of the widget function are organized in a structure which is
the uvalue of the main base.
I am prefering pointer instead of a common block.
Unfortunately this was not the answer of the question.
Regards
R.Bauer
PRO list_ex_event, Event
WIDGET_CONTROL,event.top,get_uvalue=map
CASE event.id OF
(*map).id_show: BEGIN
idx=WIDGET_INFO((*map).id_list,/list_select)
PRINT,(*map).data.list_value[idx]
END
(*map).id_done: WIDGET_CONTROL,event.top,/destroy
ELSE:
ENDCASE
END
PRO list_ex
map=CREATE_STRUCT('id_base_0',WIDGET_BASE(SCR_XSIZE=300 ,SCR_YSIZE=200 ,$
TITLE='list example' ,SPACE=3 ,XPAD=3 ,YPAD=3))
value=['alpha','beta','gamma','delta']
map=CREATE_STRUCT(map,'id_list',WIDGET_LIST(map.id_base_0, Uvalue='LIST'
,$
XOFFSET=9 ,YOFFSET=10 ,SCR_XSIZE=118 ,SCR_YSIZE=138 ,XSIZE=11
,YSIZE=2,$
value=value,/multiple))
map=CREATE_STRUCT(map,'id_show', WIDGET_BUTTON(map.id_base_0,
Uvalue='SHOW', $
XOFFSET=151 ,YOFFSET=18 ,/ALIGN_CENTER ,VALUE='SHOW'))
map=CREATE_STRUCT(map,'id_done', WIDGET_BUTTON(map.id_base_0,
Uvalue='DONE', $
XOFFSET=151 ,YOFFSET=48 ,/ALIGN_CENTER ,VALUE='DONE'))
map=CREATE_STRUCT(map,'Data',CREATE_STRUCT('list_value',valu e))
map=PTR_NEW(TEMPORARY(map))
WIDGET_CONTROL, /REALIZE, (*map).id_BASE_0,set_uvalue=map
XMANAGER, 'list_ex', (*map).id_BASE_0
ptr_free,map
END
|
|
|
|
|
Re: pulldown menu with multiple selections - Yes we can! [message #17709 is a reply to message #17538] |
Tue, 09 November 1999 00:00  |
Michael Asten
Messages: 53 Registered: March 1999
|
Member |
|
|
"R.Bauer" wrote:
> Dear Michael,
>
> this is a bit more modern code of your widget.
> The arrangement of the widget was done by the GUI Builder too. An important
> difference to your code is
> thats the ids of the widget function are organized in a structure which is
> the uvalue of the main base.
> I am prefering pointer instead of a common block.
>
> Unfortunately this was not the answer of the question.
But an illuminating example of how to improve. Thanks for the tip.
Regards,
Michael Asten
|
|
|