pub static mouseClicked: MouseClickedInternalTypeExpand description
The mouseClicked() function is called once after a mouse button has been
pressed and then released.
Browsers handle clicks differently, so this function is only guaranteed to be
run when the left mouse button is clicked. To handle other mouse buttons
being pressed or released, see mousePressed() or mouseReleased().
Browsers may have different default
behaviors attached to various mouse events. To prevent any default
behavior for this event, add "return false" to the end of the method.
Examples
// Click within the image to change
// the value of the rectangle
// after the mouse has been clicked
let value = 0;
function draw() {
fill(value);
rect(25, 25, 50, 50);
}
function mouseClicked() {
if (value === 0) {
value = 255;
} else {
value = 0;
}
}function mouseClicked() {
ellipse(mouseX, mouseY, 5, 5);
// prevent default
return false;
}// returns a MouseEvent object
// as a callback argument
function mouseClicked(event) {
console.log(event);
}Parameters
event? optional MouseEvent callback argument.