Making multiple selections in a listbox
Peeyush Khare
Hi All,
I have a list box in a panel that contains names of chemical compounds. I can select any one of them to plot its time series. What I want to do now is to be able to select multiple compounds and overplot their timeseries on the same graph. However, I couldn't figure out what do I need to change in the listbox settings to allow for multiple selections. Kindly advise.
Also how can I make a multi-column listbox?
Thanks,
Peeyush
Hi,
In the listbox control dialog box, adjust the selection mode as needed. If you are coding it you can use mode flag
mode=m List selection mode specifying how many list selections can be made at a time.
m =0: No selection allowed.
m =1: One or zero selection allowed.
m =2: One and only one selection allowed.
m =3: Multiple, but not disjoint, selections allowed.
m =4: Multiple and disjoint selections allowed.
When multiple columns are used, you can enable individual cells to be selected using modes 5,6,7 and 8 in analogy to m =1-4. When m =3 or 4 is used with multiple columns then only the first column of the selWave is used to indicate selections. Checkboxes and editing mode, however, use all cells even in modes 0-4.
Modes 9 and 10 are the same as modes 4 and 8 except they use different selection rules and require testing bit 3 as well as bit 0 in selWave. In modes 4 and 8, a shift click toggles individual cells or rows, but in modes 9 and 10, the Command (Macintosh ) or Ctrl (Windows ) key can be used to toggle individual cells or rows while the Shift key is used to define a rectangular selection. To determine if a cell is selected, perform a bitwise AND with 0x09.
Andy
May 24, 2021 at 10:05 am - Permalink
In reply to Hi, In the listbox… by hegedus
Hi Andy,
So I tried "Multiple continguous rows" and "Multiple disjoint rows" options before but every time I select them, I just get a big red cross in the list. I tried increasing the physical length of the list by dragging the edges just in case that did something but it had no effect. Only "One or no rows" seem to work so I could only make one selection in the list.
Could you please advise how I could overcome this problem? Is there something else as well in the setting that needs to be changed for multiple rows selection to work?
My list is a 1D text wave.
Sincerely,
Peeyush
May 24, 2021 at 12:22 pm - Permalink
Hi Peeyush.
Here is a simple toy experiment I cobbled together for a list box.
I am curious about the error you are getting and am wondering do you have a selection wave. The selection wave is a numeric wave the same length as your text wave and identified in the listbox control dialog box. It will receive the data of the selected wave. In my experiment, fred is the selection wave and lucy is the text wave.
Andy
May 24, 2021 at 12:50 pm - Permalink
Hi Andy,
Thanks a ton for putting together this example. It explains a lot. So I was not putting in a selection wave. Without it, the "One or no rows" option worked just fine. However, others did not.
I'm very curious what is the purpose of the numeric selection wave? When I create one (same dimensions as the list text wave), do I need to set all values to 0 initially or 1 or just leave all cells as nan.
Also why did "One or no rows" option worked without the selection wave?
Thank you so much for all the advice!!
Sincerely,
Peeyush
May 24, 2021 at 12:57 pm - Permalink
Hi KPeeyush,
The selection wave is needed when handling multiple responses when you are checking the status of the listbox. For single item when you do a controlinfo on the check box it returns a V_Value of the selected row. If you had more than one then the single value in controlinfo would be sufficient you need more values. So the technique is to initialize the wave to zero (not selected) and the control will set the value to 1 for the selected cell/rows. It is then up to you to cycle through the selection wave and work on the highlighted cells. In my toy example, I go through the selection wave and if 1 (i.e. true selected) it prints the corresponding values to the history.
Andy
May 24, 2021 at 01:04 pm - Permalink
Hi Andy,
Thank you so much for explaining the sinews. This is extremely helpful!
Last question (for now :) ) For a list where I also put in a selection wave to be able to make multiple selections, could I still use the "V_value" if I'm making only one selection? or, do I necessarily have to go the for loop route for one selection as well?
Sincerely,
Peeyush
May 24, 2021 at 01:55 pm - Permalink
I gave it a shot in your example. It didn't work. V_value always returned 0 so I assume that's the answer. Thanks!
May 24, 2021 at 02:12 pm - Permalink
Hi Peeyush,
Nope. In the documentation for controlinfo under the listbox section, the returned value of V_Value will be -1.
ListBox V_flag 11
V_Value Currently selected row (valid for mode 1 or 2 or modes 5 and 6 when no selWave is used). If no list row is selected, then it is set to -1.
Andy
May 24, 2021 at 02:13 pm - Permalink
Got it, thanks a lot! Really appreciate the help!
May 24, 2021 at 03:31 pm - Permalink