Programmer Reference : Common Widgets : List widgets : Multiple selection lists
Multiple selection lists
In the following example, the list widget shown at right is created with its selection policy set to XmMULTIPLESELECT. A multiple selection callback is added, to correspond with the selection policy.
| items shell list |
items := #('item1' 'item2' 'item3' 'item4' 'item5').
shell := CwTopLevelShell
createApplicationShell: 'shell'
argBlock: nil.
list := shell
createList: 'list'
argBlock: [:w |
selectionPolicy: XmMULTIPLESELECT;
items: items].
addCallback: XmNmultipleSelectionCallback
receiver: self
selector: #multipleSelect:clientData:callData:
clientData: nil.
list manageChild.
shell realizeWidget.

Multiple-selection list
The call data of the multipleSelection callback specifies the items that were selected. The callback method below prints the entire callback data on the transcript. All components of the call data can be retrieved using the corresponding accessor method.
multipleSelect: widget clientData: clientData callData: callData
"Print the call data."
Transcript cr; show: 'Multiple selection call data: ',
callData printString
If Item 2 and Item 3 were selected in order, as in the illustration, the transcript output would be:
Multiple selection call data: CwListCallbackData(
reason -> 24
item -> 'Item 3'
itemPosition -> 3
selectedItems -> OrderedCollection ('Item 2' 'Item 3')
selectedItemCount -> 2
selectedItemPositions -> OrderedCollection(2 3))
Last modified date: 04/18/2020