From Test-Scratch-Wiki

Translate: - English - 中文 
Mouse Down?
2.0 Mouse Down.png
Category Sensing
Type Boolean

The Mouse Down? block is a Sensing block and a Boolean block. The block checks if the computer mouse's primary button is activated (being clicked).

Example Uses

As this block checks if the mouse is being clicked, it is useful for simulating clicks anywhere, even on the scripting area (not perfectly, however) and especially with one sprite one script projects; if the project requires clicking, this block can be used to serve as a replacement for the When () Clicked block, as the Hat block cannot be used in the middle of a script.

Some common uses for the Mouse Down? block:

  • Sensing when an object should be lifted with the Not () block (when the mouse is not held anymore)
forever 
if <mouse down?> then
wait until <not <mouse down?>>
repeat until <mouse down?>
go to [mouse-pointer v]
end
wait until <not <mouse down?>>
  • Sensing with draggable objects
  • Recording mouse clicks
when gf clicked
reset timer
forever 
if <mouse down?> then
set [down v] to (timer)
wait until <not <mouse down?>>
set [up v] to (timer)
set [elapsed v] to ((up) - (down))
add (down) to [mouse-downs v]
add (up) to [mouse-ups v]
add (elapsed) to [down times v]

Variants

In some Scratch modifications, there are similar blocks which allow the user to detect other mouse buttons; either the right-click or left-click button.

Some Scratchers wanted this feature to be implemented in Scratch itself.[1]

See Also

References

  1. http://scratch.mit.edu/discuss/topic/9811/