| myPen | myPen := Pen new defaultNib: 2. myPen up. myPen goto: Sensor mousePoint. myPen down. [Sensor waitButton. Sensor yellowButtonPressed] whileFalse: [Sensor redButtonPressed ifTrue: [myPen goto: Sensor mousePoint]].
Another version:| myPen | myPen := Pen new defaultNib: 2; place: Sensor mousePoint. [Sensor waitButton ; yellowButtonPressed] whileFalse: [Sensor redButtonPressed ifTrue: [myPen goto: Sensor mousePoint]].
| myPen | myPen := Pen new defaultNib: 2. myPen up; goto: Sensor mousePoint; down. [Sensor waitButton ; yellowButtonPressed] whileFalse: [Sensor redButtonPressed ifTrue: [myPen goto: Sensor mousePoint]].
Why This is Interesting:
When you demonstrate this, be sure to draw over window boundaries, through scroll bars, and over title bars.
In my classes, when I do this for undergraduate and graduate students who have grown up with Microsoft Windows and the Apple Macintosh, their jaws drop. "But, you can't do that!" Suddenly, windows become software: You can draw on them, change them, do something different with them. That's scary. They tell me how inherently unreliable this is, to have windows that you can change. Yeah. Freedom is scary. :-) –Mark Guzdial
(Changed to use #place: instead of #up;#goto:;#down and to increase cascading – FeatureWishList)