title: Processing IDE - Double Click on Buttons for Different Conditions
body: <p>There are 4 areas on my LED Ring and I made 4 buttons for choosing them.
  I want to be able to use these areas for different combinations.</p>
  <p>So my aim is:</p>
  <p>One click on the button: Selected area is active.</p>
  <p>Double click on on the button: Selected area is deactive.</p>
  <p>I know there is a function called mousePressed() but I couldn't implement it to my buttons with a double-click condition.</p>
  <p>Here is the piece of my code of from processing:</p>
  <pre><code>  Group AreaGroup = cp5.addGroup(&quot;AREAS&quot;)
      .setPosition(290,50)
      .setWidth(150)
      .setHeight(30)
      .setFont(font2)
      .moveTo(SetupGroup);
      background(0);
      noStroke();
      ;
      
      cp5.addButton(&quot;AREA_1&quot;)  // The button
      .setPosition(-15,10)     // x and y relative to the group
      .setSize(90, 50)       // (width, height)
      .setFont(font)
      .moveTo(AreaGroup);   // add it to the group 
      ;     
    
    
      cp5.addButton(&quot;AREA_2&quot;)  // The button
      .setPosition(90,10)    // x and y relative to the group
      .setSize(90, 50)       // (width, height)
      .setFont(font) 
      .moveTo(AreaGroup);   // add it to the group  
    ; 
    
      cp5.addButton(&quot;AREA_3&quot;)  // The button
      .setPosition(-15,80)     // x and y relative to the group
      .setSize(90, 50)       // (width, height)
      .setFont(font)
      .moveTo(AreaGroup);   // add it to the group 
      ;     
    
    
      cp5.addButton(&quot;AREA_4&quot;)  // The button
      .setPosition(90,80)    // x and y relative to the group
      .setSize(90, 50)       // (width, height)
      .setFont(font) 
      .moveTo(AreaGroup);   // add it to the group  
    ;
    
       cp5.addButton(&quot;ALL&quot;)  // The button
      .setPosition(190,45)    // x and y relative to the group
      .setSize(90, 50)       // (width, height)
      .setFont(font) 
      .moveTo(AreaGroup);   // add it to the group  
    ; 
  
  void AREA_1(){
    println(&quot;AREA_1&quot;);
    if (port != null) port.write(&quot;a\n&quot;);
  }
  
  void AREA_2(){
    println(&quot;AREA_2&quot;);
    if (port != null) port.write(&quot;b\n&quot;);
  }
  
  void AREA_3(){
    println(&quot;AREA_3&quot;);
    if (port != null) port.write(&quot;c\n&quot;);
  }
  
  void AREA_4(){
    println(&quot;AREA_4&quot;);
    if (port != null) port.write(&quot;d\n&quot;);
  }
  
  void ALL(){
    println(&quot;ALL&quot;);
    if (port != null) port.write(&quot;t\n&quot;);
  }
  </code></pre>
  <p>And here is the code pieces from Arduino</p>
  <pre><code>switch(state){
  
          case 'p':
          Serial.println(F(&quot;ex.&quot;));
          break;
  
          case 's':
          Serial.println(F(&quot;Start&quot;));
            start = true;
          break;
  
          case '1':
          Serial.println(F(&quot;Switching to ring #1&quot;));
            updateRing1 = true;
            updateRing2 = false;
          break;
          
          case '2':
            Serial.println(F(&quot;Switching to ring #2&quot;));
            updateRing1 = false;
            updateRing2 = true;
          break;
          
          case 'a':
            Serial.println(F(&quot;Area1&quot;));
            Area1 = true;
          break;  
  
          case 'b':
            Serial.println(F(&quot;Area2&quot;));
            Area2 = true;
          break;
  
          case 'c':
            Serial.println(F(&quot;Area3&quot;));
            Area3 = true;
          break;
  
          case 'd':
            Serial.println(F(&quot;Area4&quot;));
            Area4 = true;
          break;
  
           case 't':
            Serial.println(F(&quot;All the leds are choosen&quot;));
            total = true;
            Area1 = false;
            Area2 = false;
            Area3 = false;
            Area4 = false;
          break; 
  </code></pre>
  <p><a href="https://i.stack.imgur.com/7cl2x.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7cl2x.png" alt="enter image description here" /></a></p>