Programmer Reference : Common Widgets : List widgets : Single selection lists
Single selection lists
In the following example, the list widget shown at right is created with its selection policy set to XmSINGLESELECT. A single 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 |
w
selectionPolicy: XmSINGLESELECT;
items: items].
list
addCallback: XmNsingleSelectionCallback
receiver: self
selector: #singleSelect:clientData:callData:
clientData: nil.
list manageChild.
shell realizeWidget.
 
 

List widget
The call data of the singleSelection callback specifies the item that was 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.
singleSelect: widget clientData: clientData callData: callData
"Print the call data."
Transcript cr; show: 'Single selection call data: ',
callData printString
If Item 2 is selected, as in the illustration, the transcript output is as follows:
Single selection call data: CwListCallbackData(
reason -> 23
item -> 'Item 2'
itemPosition -> 2
"These three fields of the callback data are only used for multiple
and extended select lists."
selectedItems -> nil
selectedItemCount -> nil
selectedItemPositions -> nil)
Last modified date: 04/18/2020