Sensor vs. Hand (was: Re: Squeak-3.7: Title-Bar Buttons)
ducasse
ducasse at iam.unibe.ch
Fri Mar 5 08:59:48 UTC 2004
hi andreas
I need your help :) about ActiveHand use instead of Sensor
> HandMorph>>anyButtonPressed
>
> ^ lastMouseEvent anyButtonPressed
to give try I added that method in HandMorph and I changed my turtle
code to be
Turtle>>anyButtonPressed
(Delay forMilliseconds: 2) wait.
^ ActiveHand anyButtonPressed
I put that in turtle just so that people do not have to type too much
(note that this is clearly bad but this is another discussion
related to the problem I have with morphic concurrency. I played with
scratch and I understand what you meant in a previous thread)
Turtle>>wand
"self new wand"
[self anyButtonPressed]
whileFalse: [self go: 30 atRandom.
self turnLeft: 30 atRandom]
With this code, I cannot stop the turtle to loop when I pressed on
shift or any key and mouse.
If I removed the delay the squeak just blocks completely.
While with
Turtle>>anyButtonPressed
(Delay forMilliseconds: 2) wait.
^ Sensor anyButtonPressed
The loop stops as soon as I click.
So I went down in the HandMorph I tried to register my turtle to event:
in an inspector I did
ActiveHand addKeyboardListener: self
But I do not know what do I get and how I should handle that.
The methods says addKeyboardListener: anObject
"Make anObject a listener for keyboard events. All keyboard
events will be reported to the object."
But no more. So I looked into Object to see but it seems that the
event mentioned there
are related to the on:send:... one
So if you can enligth me, please do it.
Stef
More information about the Squeak-dev
mailing list
|