:) you see you found my mail Tx for the record of our discussions. On Sep 7, 2011, at 5:03 PM, Igor Stasenko wrote:
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.