Home Segments Index Top Previous Next

869: Mainline

The newModelValue method determines the position of the cursor by sending the sensor the lastUpPoint message. You obtain the width of the window from the companion viewer using the view message. You obtain minimum and maximum values for the meter's value from the companion viewer, using getMin and getMax, two newly defined Meter getters. In the event that the pointer is in the window, but is not between the minimum and maximum values, the new model value is the same as the previous model value:

Meter method definition • instance 
getMin ^ min 
Meter method definition • instance 
getMax ^ max 
MeterController method definition • instance 
newModelValue 
  | pointerPosition windowWidth meterWidth proportion | 
  pointerPosition := self sensor lastUpPoint x. 
  windowWidth := self view bounds width. 
  meterWidth := windowWidth * 3 // 4. 
  proportion := ((pointerPosition - (windowWidth * 1/8)) / meterWidth). 
  proportion >= 0 & proportion <= 1 
    ifTrue: [^ proportion * (self view getMax - self view getMin)] 
    ifFalse: [^ self view model value]