[Squeakland] please help - trouble with mouseDown, mouseUp, and looklike

Scott Wallace scott.wallace at squeakland.org
Mon Sep 1 18:33:58 PDT 2008


On Sep 1, 2008, at 3:27 PM, Nicholas Bennett wrote:

> I have some odd behavior. It seems like what I am doing is  
> reasonable and the kind of thing anyone might want to do, I am  
> hoping someone can tell me how I am misunderstanding.
>
> I want to get the effect of a sketch button via eToys scripting - to  
> let the kids make an active and engaging button to fire a script. It  
> should change it's image to a 'button down' version on mouseDown and  
> restore it on mouseUp.
>
> I tried the following:
> a - paint a sketch
> b - make a script, 'down', to 'sound croak', set it to run on  
> mouseDown
> c - make a script, 'up',  to 'sound motor', set it to run on mouseUp
> That all works fine - you get the appropriate sound on the up and  
> down events.
>
> Now to extend it to make the button up/down appearance:
> 1 - prepare two sketches for up and down
> 2 - add 'sketch lookslike downSketch' to the 'down' script
> 3 - add 'sketch lookslike upSketch' to the 'up' script
> Only the 'down' script now fires. If I turn the 'down' script to run  
> normally then the 'up' script runs on mouseUp.
>
> What am I doing wrong? How can I get the effect I am looking for?


Hi Nicholas,

To get this to work, don't use "look like", which changes the identity  
of the morph that is fielding the mouse-down/mouse-up sequence in mid- 
stream.

Instead, use assignment statements to assign appropriate values to the  
"graphic" slot of your button, using a script such as:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.jpg
Type: image/jpeg
Size: 25387 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20080901/43a69d40/pastedGraphic-0002.jpg
-------------- next part --------------



or

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedGraphic.jpg
Type: image/jpeg
Size: 28796 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20080901/43a69d40/pastedGraphic-0003.jpg
-------------- next part --------------



for the mouse-down processing, and a similar script to set the graphic  
as desired upon mouse-up. Try this -- you'll see that it works just as  
you'd like.


You were not doing anything "wrong"; it's just that use of "look like"  
in the midst of mouse-button processing evidently can screw up event- 
dispatch for the subsequent mouse-up.   This is arguably a bug --  
which hopefully will be addressed in some future version of etoys.   
For now, fortunately, you can readily achieve the result you want by  
assigning to the graphic slot rather than using "look like."

Cheers,

   -- Scott


More information about the Squeakland mailing list