This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2007-05-31 04:03:49

deegee
Scratcher
Registered: 2007-05-31
Posts: 8

Mouse click outside the stage is detected by scripts

I had a script which detected mouse clicks and started drawing. However, it was activated when the mouse was off the stage area, meaning that drawing was in a bad location.

Shouldn't the mouse input to the scripts be limited to when it is over the stage?

Hugh

Offline

 

#2 2007-05-31 08:19:17

Duncan
Scratcher
Registered: 2007-05-15
Posts: 47

Re: Mouse click outside the stage is detected by scripts

If you are testing for mouse down it will detect when a mouse button is down wherever the mouse is.  You could build a check into your script to check the mouse x and mouse y position.

Forever if mouse down and mouse x > -240
  move 10 steps
  if on edge, bounce

will move the sprite while your mouse is over the stage but it will stop if you move off to the left.  You will need to add checks for the other edges of the stage to trap the mouse clicks on the stage only.

Offline

 

#3 2007-05-31 09:54:57

deegee
Scratcher
Registered: 2007-05-31
Posts: 8

Re: Mouse click outside the stage is detected by scripts

Yes, I had to add those workarounds to make sure the mouse is on the stage.

It was kind of confusing - I was getting a red error outline around my script, and finally realised that it was due to me clicking to change the script and the clicks being detected by another script.

If Scratch is to be as simple and foolproof as possible I don't see any possible reason why you would want to know about mouse clicks (or movements) off the stage. In fact, with a bit of tricky programming you could detect what was being clicked on in the scratch workspace. Not good.

Hugh

Offline

 

#4 2007-05-31 17:11:26

UncleBits
Scratcher
Registered: 2007-05-31
Posts: 2

Re: Mouse click outside the stage is detected by scripts

I programmed a Scratch tutorial for my nephew that made use of clicks off the stage.  Please don't remove this 'feature'.

Offline

 

Board footer