Hi, i wonder how can i use your method with a boolean, like this:
import processing.event.MouseEvent;
boolean[] mouses = new boolean[2];
boolean pressLeft = true;
boolean pressRight = true;
boolean actionLM = false;
boolean actionRM = false;
int leftClick;
int rightClick;
void setup(){
size(200, 100);
registerMethod("mouseEvent", this);
}
void draw(){
background(255);
mouseLeft();
if(actionLM) leftClick+=1;
fill(0);
text("left " + leftClick, 10, 10);
mouseRight();
fill(0);
text("right " + rightClick, 10, 25);
}
void mouseLeft(){
if(pressLeft && mouses[0] == true){
actionLM = true;
pressLeft = false;
}
if(mouses[0] == false){
actionLM = false;
pressLeft = true;
}
}
void mouseRight(){
if(pressRight && mouses[1] == true){
rightClick +=1;
pressRight = false;
actionRM = true;
}
if(mouses[1] == false){
pressRight = true;
actionRM = false;
}
}
public void mouseEvent(MouseEvent e){
int button = e.getButton();
int buttonID = e.getAction();
if(buttonID == MouseEvent.PRESS){
mousePressedProcess(button);
}
if(buttonID == MouseEvent.RELEASE){
mouseReleasedProcess(button);
}
}
protected void mousePressedProcess(int button){
if(button == PConstants.LEFT) mouses[0]=true;
if(button == PConstants.RIGHT) mouses[1]=true;
}
protected void mouseReleasedProcess(int button){
if(button == PConstants.LEFT) mouses[0]=false;
if(button == PConstants.RIGHT) mouses[1]=false;
}
So, when i press the right button of the mouse, like in your example, its work.
But i’m looking to use a boolean with my left button, and when i keep the left button pressed, the count don’t stop.
How can i make the left button like the right button but with a boolean ?
So when i press the left button, the leftClick count increment by one and then i need to realese it and press it again to increment it again.
Thanks for your times guys