In the following example, an icon tree is created that displays the Smalltalk class hierarchy. The defaultActionCallback is hooked to allow navigation through the tree.
Object subclass: #IconTreeExample instanceVariableNames: 'icon' classVariableNames: " poolDictionaries: 'CwConstants EwConstants'
open | shell iconTree | shell := CwTopLevelShell createApplicationShell: 'shell' argBlock: [:w | w title: 'Icon Tree Example']. iconTree := shell createScrolledIconTree: 'iconTree' argBlock: [ :w | w items: (Array with: Object)].
iconTree addCallback: XmNvisualInfoCallback receiver: self selector: #visualInfo:clientData:callData: clientData: nil;
addCallback: XmNchildrenCallback receiver: self selector: #children:clientData:callData: clientData: nil;
addCallback: XmNdefaultActionCallback receiver: self selector: #defaultAction:clientData:callData: clientData: nil.
"Note: The destroyCallback is not shown." icon := shell screen getIcon: 'default_xm_information' foregroundColor: CgRGBColor black. iconTree manageChild. shell realizeWidget.
children: widget clientData: clientData callData: callData "Provide the children of the object contained in the callData." callData children: callData item subclasses.
defaultAction: widget clientData: clientData callData: callData "Toggle the expand and collapse state of the item in the callData." widget expandCollapsePos: callData itemPosition notify: false
visualInfo: widget clientData: clientData callData: callData "Provide the icon and label for the class contained in the callData. Also check whether the item has children." callData icon: icon; label: callData item name; hasChildren: callData item subclasses notEmpty