On Scratch it is possible to write handlers for the following events:
- when GreenFlag clicked
- when <key> pressed
- when <sprite> clicked
- when I receive <message>
Is it possible to handle also events:
- when sprite dragged by user to new location
- when mouse button pressed, when released and to distinguish among left and right buttons
?
Offline
when flag clicked, when [ ] key pressed, when [ ] clicked, and when I receive [ ]: There's already blocks for them...
when sprite dragged: first, make sure its draggable!
Make Variables: OldX, OldY
when sprite clicked
set [ OldX ] to ( x position )
set [ OldY ] to ( y position )
repeat until < not < mouse down > >
if < not < ( x position ) = ( OldX ) > >
broadcast [ dragged ]
stop script
if < not < ( y position ) = ( OldY ) > >
broadcast [ dragged ]
stop script
when mouse button pressed (distinguish)
copy to all sprites AND stage:
when sprite/stage clicked
if < mouse down >
broadcast [ left mouse button down ]
else
broadcast [ right mouse button ]
Offline