[FIX] Value parameter in interrupt requests is global

David N. Smith (IBM) dnsmith at watson.ibm.com
Sat Feb 17 01:08:56 UTC 2001


All:

The #on:send:to:withValue messages to Morph keeps separate selector (send:), and targets (to:) but only keeps the most recent value (withValue:). The value is used in any other three part selector that follows even if it is specified in an #on:send:to:. Thus, sending:

	on: #mouseDown send: #mouseDownEvent:noteMorph:pitch: to: self 
		withValue: i-1*12 + (#(2 4 7 9 11) at: j))

sets the value and it is returned for cases like these:

	on: #mouseMove send: #mouseMoveEvent:noteMorph:pitch: to: self;
	on: #mouseUp send: #mouseUpEvent:noteMorph:pitch: to: self;

(examples from PianoKeyboardMorph which takes advantage of this anomaly.)

If one attempts to have different values for each interrupt type, only the most recent is remembered and is send back for all interrupt types.

The event handler should really keep a value for each kind of interrupt. Code like the above is confusing at best, and broken at worst. It should actually pass the proper value back.

Attached is a fix for this problem, coded for backward compatibility so that it uses the global value when no value is specified. When all places that take advantage of the anomaly are gone this compatibility should be removed.

Also attached is a small class which tests the code and shows that it can indeed answer different values. Note that PianoKeyboardMorph is unmodified and still works.

Dave
-------------- next part --------------
Skipped content of type multipart/appledouble-------------- next part --------------
-- 
_______________________________
David N. Smith
IBM T J Watson Research Center
Hawthorne, NY
_______________________________
Any opinions or recommendations
herein are those of the author  
and not of his employer.


More information about the Squeak-dev mailing list