Zho:滑鼠键被按下？（积木）

The Mouse Down? 积木 is a 侦测类积木 and a 菱形积木. The block checks if the 计算机的滑鼠's primary button is activated (being clicked).

用法示例
As this block checks if the mouse is being clicked, it is useful for simulating clicks anywhere, even on the 程式工作区 (not perfectly, however) and especially with 一角色一脚本类专案; if the 专案 requires clicking, this block can be used to serve as a replacement for the 当角色被点击 block, as the 半圆形积木 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 不成立 block (when the mouse is not held anymore)

重複無限次 如果 <滑鼠鍵被按下？> 那麼 等待直到 <<滑鼠鍵被按下？> 不成立> 重複直到 <滑鼠鍵被按下？> 定位到 [滑鼠游標 v] 位置 end 等待直到 <<滑鼠鍵被按下？> 不成立> end end


 * Sensing with draggable objects


 * Recording mouse clicks

當 @greenflag 被點擊 計時器重置 重複無限次 如果 <滑鼠鍵被按下？> 那麼 變數 [down v] 設為 (計時器) 等待直到 <<滑鼠鍵被按下？> 不成立> 變數 [up v] 設為 (計時器) 變數 [elapsed v] 設為 ((up) - (down)) 新增項目 (down) \( [mouse-downs v] \) 新增項目 (up) \( [mouse-ups v] \) 新增項目 (elapsed) \( [down times v] \) end end

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.

参见

 * 滑鼠游标的 X
 * 滑鼠游标的 Y
 * 滑鼠右键的侦测