Processing, mouseButton
用法介紹。
說明
當按下鼠標按鈕時,係統變量 mouseButton
的值將設置為 LEFT
、 RIGHT
或 CENTER
,具體取決於按下的按鈕。 (如果沒有按下按鈕,mouseButton
可能會重置為 0
。因此,最好先使用 mousePressed
測試是否有任何按鈕被按下,然後再測試 mouseButton
的值,如上例所示。)
例子
// 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);
}
// Click within the image and press
// the left and right mouse buttons to
// change the value of the rectangle
void draw() {
rect(25, 25, 50, 50);
}
void mousePressed() {
if (mouseButton == LEFT) {
fill(0);
} else if (mouseButton == RIGHT) {
fill(255);
} else {
fill(126);
}
}
相關用法
- Processing mouseY用法及代碼示例
- Processing mouseMoved()用法及代碼示例
- Processing mouseDragged()用法及代碼示例
- Processing mouseX用法及代碼示例
- Processing mouseWheel()用法及代碼示例
- Processing mouseClicked()用法及代碼示例
- Processing mouseReleased()用法及代碼示例
- Processing mousePressed()用法及代碼示例
- Processing mousePressed用法及代碼示例
- Processing modelX()用法及代碼示例
- Processing month()用法及代碼示例
- Processing modelY()用法及代碼示例
- Processing movieEvent()用法及代碼示例
- Processing modelZ()用法及代碼示例
- Processing match()用法及代碼示例
- Processing minute()用法及代碼示例
- Processing max()用法及代碼示例
- Processing matchAll()用法及代碼示例
- Processing map()用法及代碼示例
- Processing millis()用法及代碼示例
- Processing mag()用法及代碼示例
- Processing min()用法及代碼示例
- Processing FFT用法及代碼示例
- Processing SawOsc.pan()用法及代碼示例
- Processing FloatDict用法及代碼示例
注:本文由純淨天空篩選整理自processing.org大神的英文原創作品 mouseButton。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。