mousePressed

v0.1.7
mousePressed(button);Event

Called when a mouse button is pressed.

Arguments

buttonThe pressed mouse button


In the following example, the circle's size increases when the user clicks the mouse.

size = 12;

function setup()
  createWindow(400, 400);
  textAlign(CENTER);
end

function draw()
  background('purple');
  
  text('Click to grow the circle', width/2, 50);
  circle(width/2, height/2, size);
end

-- Increase circle size when mouse pressed
function mousePressed()
  size = size + 3;
end

Output

See mousePressed in mouse.h