On 7 September 2011 10:53, Stéphane Ducasse <Stephane.Ducasse@inria.fr> wrote:
Hi igor
how should I convert code like that
[ Sensor anyButtonPressed ] whileFalse: Â Â Â Â Â Â Â Â [ aBitBlt destOrigin: Sensor cursorPoint. Â Â Â Â Â Â Â Â aBitBlt copyBits ].
So that it avoid polling?
Should we change
contents := (Sensor shiftPressed not) Â Â Â Â Â Â Â Â ifTrue: [currentCompiledMethod decompileWithTemps] Â Â Â Â Â Â Â Â ifFalse: [currentCompiledMethod decompile]. Â Â Â Â contents := contents decompileString asText makeSelector
For examples which using some drawing on screen, i think best would be to implement a custom morph, which accepts a block for drawing stuff in it. Then example code could draw there, and open it in morph. Then once used no longer amused, he can just close morph/window instead of waiting for mouse clicks etc etc. For things like shift-key pressed, a code should use events /hand to extract the key statuses, but not sensor. One of reasons for that, if we could have an event recorder & event player, all tests/examples could use them. But if you refer directly to Sensor, such scenarios are not possible, since sensor provides an actual status of keyboard/events whatever.
or [(nextEvent := Sensor peekEvent) isNil] whileFalse:   [nextEvent first = currentBuf first    ifFalse: [^trail contents "different event type"].   nextEvent fifth = currentBuf fifth    ifFalse: [^trail contents "buttons changed"].   nextEvent sixth = currentBuf sixth    ifFalse: [^trail contents "modifiers changed"].   "nextEvent is similar.  Remove it from the queue, and check the next."   nextEvent := Sensor nextEvent.   nextEvent    ifNotNil: [ trail nextPut: nextEvent third @ nextEvent fourth ]].
Then when I install the nonpolling behavior     InputEventSensor installPollingEventSensorFramework the menu of the world gets sluggish (may be I do not use the right VM BTW).
yes, you using old VM, which for some reason not awaking the fetcher process immediately once new events arrived from OS.
Stef
-- Best regards, Igor Stasenko AKA sig.