The-IT
The-IT

Reputation: 728

mouseClicked() won't execute while mouse is in motion

So basically the title says it all. I tried searching around; you would think something as trivial as this would have instant results, but nope.

This is really annoying me. Can anyone suggest a fix or workaround? Thanks

Upvotes: 1

Views: 34

Answers (1)

Kevin Workman
Kevin Workman

Reputation: 42174

That's because, by definition, a mouse click while in motion is no longer a mouse click, it's a drag event.

You still have access to the mousePressed() and mouseReleased() events, so if you want to detect a mouse click during a drag event, use those instead.

Here's a small example to get you started:

void mouseClicked(){
  println("clicked");
}

void mousePressed(){
 println("pressed"); 
}

void mouseReleased(){
  println("released");
}

void mouseDragged(){
 println("dragged"); 
}

void draw(){
  background(0);
}

Upvotes: 2

Related Questions