Home Segments Index Top Previous Next

710: Mainline

Now, you need to connect to the meter changing food names and changing food-calorie values. One way to connect them is to redefine the itemSelected: callback method, defined previously in Segment 698, such that itemSelected: sends messages to the meter, identified by the name identified by the definition shown in Segment 705.

CalorieViewManager method definition • instance 
itemSelected: theListBox 
  food := foodList at: theListBox selection. 
  (self paneNamed: 'CalorieMeter') 
    setValue: food tCalories; 
    event: #display. 

The first message sent to the meter sets the value variable. The second message tells the meter to act as though the #display event has occurred, as explained in Segment 707.