We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Re: Detecting multiple mouse buttons
Page Index Toggle Pages: 1
Re: Detecting multiple mouse buttons? (Read 533 times)
Re: Detecting multiple mouse buttons?
Oct 4th, 2005, 5:37pm
 
It's fairly simple, just have a boolean for each mouse button, set it to true when the button is pressed, and set it to false when released. That way you can test which buttons are currently pressed at any time you want.

e.g.

Code:

boolean left=false;
boolean right=false;
boolean center=false;

void mousePressed()
{
if(mouseButton==LEFT)
left=true;
if(mouseButton==RIGHT)
right=true;
if(mouseButton==CENTER)
center=true;
}

void mouseReleased()
{
if(mouseButton==LEFT)
left=false;
if(mouseButton==RIGHT)
right=false;
if(mouseButton==CENTER)
center=false;
}
Page Index Toggle Pages: 1