Application Developer Guide > Using Wave Widgets > Creating a Scrolling List
  

Creating a Scrolling List
A scrolling list allows the user to select one or more items from a list of items. The “items” in a scrolling list are text strings, defined in a string array. Scroll bars are provided for lists that are too long to display in the scrolling list window.
Use the WwList function to create a scrolling list.
Selection Mode
You can create a scrolling list in one of two selection modes: single or multiple selection.
Single Selection Mode
This is the default selection mode. Single selection means that the user can select one item at a time. To select an item, the user positions the pointer over the item and clicks the SELECT mouse button, usually the left button. If the user selects another item, the first item is deselected. This then executes the selectCallback routine.
If the user double-clicks on an item, the defaultCallback routine is executed.
Multiple Selection Mode
In multiple selection mode, the user can select more than one item from the list. The first item is selected with left mouse button. Additional items can then be selected using left mouse button. To deselect an item, the user clicks the left mouse button on it.
Scrolling List Callbacks
Two callbacks are used with the WwList function. The first one, selectCallback, is called whenever the user selects an item (single-clicks on it). The second callback, defaultCallback, is called when the user double-clicks on an item. This callback is called “default” because it usually executes a default action. For example, the Motif file selection widget operates in this manner. When the user clicks on a file name, the text is placed in a text input field. When the user double-clicks on a file name, the file is selected, the selection widget is dismissed, and the defaultCallback is called. For an illustration of the Motif file selection widget, see "Creating a File Selection Widget".
Example
The following example creates a scrolling list containing the names of holidays. The Visible keyword specifies the number of items that are displayed in the scrolling list at a time. The Multi keyword sets the scrolling list to the multiple selection mode. The result is shown in Scrolling List.
top=WwInit('ww_ex13', 'Examples', layout)
; Define the list of items.
items = ['PresidentsDay', 'St.PatricksDay', 'Easter', $
'MemorialDay', '4th of July', 'LaborDay', 'Halloween', $
'Thanksgiving', 'Hanukkah', 'Christmas', 'New Years Eve']
; Create a scrolling list widget that displays the list of
; holidays.
list=WwList(layout, items, 'ListCB', $
'DefaultCB', Visible=7,/Multi, Left=rbox, Top=controls)
status=WwSetValue(top, /Display)
WwLoop
 
Figure 5-22: Scrolling List

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.