Help with button objects

looks like at any mouse click all buttons are deactivated, bad
( if anywhere on canvas, freq select window, or not this option group )

and on click on one button only this one is activated. good

OPTION GROUP need separate handling, example:


void mouseClicked(){
  if (mouseX >=0 && mouseX <= width && mouseY >= 80 && mouseY <= height-50)   {   //select freq and send it
    sendOSCMsg(freq, "/freq");
    drawFixed = mouseX;
  }

  //check if any btn ( OF THIS OPTION GROUP ) was clicked
  int thisone = -1;
  for (int i=0; i<3; i++) if ( btnsFreqRange[i].btnClicked() ) thisone = i;
  if (thisone > -1 ) {
    for (int i=0; i<3; i++) {
      if ( thisone == i ) {
        maxFreq = btnsFreqRange[i].btnGetVal();
        btnsFreqRange[i].btnSetActive();
        //kll btnsFreqRange[i].btnDisplay();
      } else   btnsFreqRange[i].btnSetInactive();
    }
  }

  //check if any btn ( OF THIS OPTION GROUP ) was clicked
  thisone = -1;
  for (int i=0; i<10; i++) if ( btnsIntensity[i].btnClicked() ) thisone = i;
  if (thisone > -1 ) {
    for (int i=0; i<10; i++) {
      if ( thisone == i ) {
        sendOSCMsg((float)btnsIntensity[i].btnGetVal(), "/int");
        btnsIntensity[i].btnSetActive();
        //kll btnsIntensity[i].btnDisplay();
      } else
        btnsIntensity[i].btnSetInactive();
    }
  }
  
  
}

2 Likes