Home Segments Index Top Previous Next

698: Mainline

The select event calls on the itemSelected: callback method when you click the mouse on a displayed item. For the moment, the itemSelected: callback method merely displays in the transcript the name of the selected food. To identify the selected food, itemSelected: uses the selection message to obtain the index of the selected name in the displayed list; then itemSelected: uses the at: message to obtain the corresponding Food instance from the Food-instance collection:

CalorieViewManager method definition • instance 
itemSelected: theListBox 
  food := foodList at: theListBox selection. 
  Transcript show: food name; cr.