首页 > 文档 > mouseButton鼠标按钮
2017
07-14

mouseButton鼠标按钮

1-1.mouseButton

Name(名称):mouseButton//鼠标按钮

Examples(例子):

// Click within the image and press点击图片并按下鼠标按钮

// the left and right mouse buttons to左边和右边的鼠标按钮

// change the value of the rectangle改变矩形的颜色

void draw() {

if (mousePressed && (mouseButton == LEFT)) {

fill(0);

} else if (mousePressed && (mouseButton == RIGHT)) {

fill(255);

} else {

fill(126);

}

rect(25, 25, 50, 50);

}

Description(描述):When a mouse button is pressed, the value of the system variable mouseButton is set to either LEFT, RIGHT, or CENTER, depending on which button is pressed. (If no button is pressed, mouseButton may be reset to 0. For that reason, it’s best to use mousePressed first to test if any button is being pressed, and only then test the value of mouseButton, as shown in the examples above.)


当按下鼠标按钮时,系统变量mouseButton的值将被设置为左、右或中心,这取决于按哪个按钮。如果没有按下按钮,鼠标按钮可以重置为0。出于这个原因,最好先使用mousePressed来测试是否有任何按钮被按下,然后才测试mouseButton的值,如上面的例子所示。

Returns(返回值):LEFT(左)

RIGHT(右)

备注:鼠标没有按下按钮或者只是滚动滚轮返回0,左键返回37,中间返回3右键返回39.(返回值是用我自己用print测试所得的)

Related(相关函数):mouseX
mouseY
pmouseX
pmouseY
mousePressed
mousePressed()
mouseReleased()
mouseClicked()
mouseMoved()
mouseDragged()
mouseWheel()


 



最后编辑:
作者:卡萨布兰卡
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。