2010/1/13 Stéphane Ducasse <stephane.ducasse@inria.fr>:
do you have one example so that I can evaluate?
there are differents use cases of referencing Sensor (Except examples which could simple be removed from the image).
- asking for the current cursor position (which is the majority of the references) e.g. 'Scanning ', aFile localName, '...'    displayProgressAt: Sensor cursorPoint    from: startPosition to: stopPosition    during: [:bar |
This could be replaced by Display center, the current active Window position or things like that.
- asking for the state of modifier keys
shift := Sensor leftShiftDown.
This needs some refactoring to hand down the current event into these methods. I already refactored a few of these methods when cleaning up the unicode handling but not all.
- the worst offender is actually polling e.g. newRectFrom: newRectBlock
... [ Sensor nextEvent isNil ] whileFalse. buttonNow := Sensor anyButtonPressed. newRect := newRectBlock value: rect. ...
I don't remember my original idea, but i offered to replace such uses by something like: Sensor captureEventsDuring: aBlock where block should accept a single event, and it should stay captured until block returns false, i.e.: Sensor captureEventsDuring: [:ev | "handle the event here" ev anyButtonPressed "keep looping if any mouse button still held" ]. Next step is removing a direct reference to Sensor global, and replace it with something like: self eventSensor
Not always easy to code around this, as you need stateful event handling to replace the polling. On the other hand it looks like the method could simply be removed as there don't seem to be any important callers left.
Michael
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- Best regards, Igor Stasenko AKA sig.