mouse

v0.1.6
mouseYGlobal

The y mouse coordinate

createWindow(400, 400);

function draw()
  background(51);
  
  line(0, mouseY, width, mouseY);
end
See mouseY in mouse.h
mouseXGlobal

The x mouse coordinate

createWindow(400, 400);

function draw()
  background(51);
  
  line(mouseX, 0, mouseX, height);
end
See mouseX in mouse.h
pmouseYGlobal

The y mouse coordinate from the previous draw call

See pmouseY in mouse.h
pmouseXGlobal

The x mouse coordinate from the previous draw call

See pmouseX in mouse.h
mouseIsPressedGlobal

Is true when the mouse is pressed, is false when it's not

See mouseIsPressed in mouse.h
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 = 0;

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

function draw()
  background(51);

  circle(mouseX, mouseY, size);
end

-- Increase circle size when mouse pressed
function mousePressed()
  size = size + 1;
end
See mousePressed in mouse.h
mouseReleased(button);Event

Called when a mouse button is released.

Arguments

buttonThe released mouse button


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

size = 32;

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

function draw()
  background(51);

  circle(mouseX, mouseY, size);
end

-- Set larger circle size
function mousePressed()
  size = 64;
end

-- Reset size
function mouseReleased()
  size = size + 6;
end
See mouseReleased in mouse.h
mouseWheel(button);Event

Called when a mouse wheel is used

Arguments

buttonThe pressed mouse button


In the following example, the circle's size changes when the user scrolls

size = 0;

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

function draw()
  background(51);

  circle(mouseX, mouseY, size);
end

-- Change circle size when mouse is scrolled
function mouseWheel(delta)
  size = size + delta;
end
See mouseWheel in mouse.h