mouseeventmouseprocessingonmouseclick

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


Solution

  • 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);
    }