Edited:
the code in this post does not work, but i left it here for a paper trail to my final solution. check like 2 posts farther down.
here is the "hacked" processing code for the click events. i am assuming they call it "hacked" because it uses some java awt stuff not wrapped by Processing?
Code:void mousePressed(MouseEvent e) {
if (e.getClickCount()==2)
println("<double click>");
if (e.getButton()==MouseEvent.BUTTON3)
println("<right button>");
// this prints out the event in descriptive form
println(e);
}
anyhow.. you will still need to implement a timer if you wanted to check for both single AND double clicks. you could do this relatively easily with the following code:
Code:int clicks = 0;
float clicktime = 0.0;
float clickspeed = 1000.0;
void draw()
{
if(clicktime > clickspeed){
println("<single click>");
clicktime = 0.0;
}
}
void mousePressed(MouseEvent e)
{
if (e.getClickCount()==1 && e.getButton()==MouseEvent.BUTTON1)
clicktime = millis();
if (e.getClickCount()==2 && e.getButton()==MouseEvent.BUTTON1){
println("<double click>");
clicktime = 0.0;
}
if (e.getClickCount()==1 && e.getButton()==MouseEvent.BUTTON3){
println("<right button>");
}
// this prints out the event in descriptive form
println(e);
}
it could be easily modified to detect double right clicks, triple (quadruple, etc.) clicks, adding a mouseReleased() method for simultaneous clicking (maybe clicking left button while right button is held, etc.)..
hope this helps. it's basically the same as the other example listed in this post, but it uses a "built-in" counter rather than implementing your own counter and using modulus, etc..
Edited:
also.. you could probably use your if statements in mousePressed() to assign a value to a variable, like "buttonPressed", that could be uniformly implemented in the draw() if-block that determines if you've beaten clickspeed. this way, you could switch(buttonPressed) in your draw() method to determine which mouse button to respond to.