Sensor vs. Hand (was: Re: Squeak-3.7: Title-Bar Buttons)

Andreas Raab andreas.raab at gmx.de
Fri Mar 5 12:44:20 UTC 2004


Hi Stef,

You're hitting the wall with regards to what Morphic can do and what it
cannot. IOW, your little example is precisely one of those "simple things"
that I referred to which are so hard to do with Morphic. In such a situation
your only choice is to go directly to Sensor.

With regard to the listeners, all events to the listener are sent via
#handleListenEvent: (so this would be the place to start looking at) but
notice that this wouldn't help you in the above. The hand simply won't get
any events while you're "blocking" in the delay.

Cheers,
  - Andreas

----- Original Message ----- 
From: "ducasse" <ducasse at iam.unibe.ch>
To: "The general-purpose Squeak developers list"
<squeak-dev at lists.squeakfoundation.org>
Sent: Friday, March 05, 2004 9:59 AM
Subject: Re: Sensor vs. Hand (was: Re: Squeak-3.7: Title-Bar Buttons)


> 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