Convert a button class for multi touch

Hello to all, i try to convert this class to obtain a multi touch possibility inside android, to pass from mousePressed, mouseX and MouseY to Touches array.
Actually it is visible only when the screen is touched.
Im unable to define if the screen is touched.

THIS IS THE STARTING POINT WITH MOUSE TRACKING

class Button{
  int xpos, ypos, wid, hei;
  String label;
  boolean over = false;
  boolean down = false; 
  boolean clicked = false;
  Button(
  int tx, int ty,
  int tw, int th,
  String tlabel
  ){
    xpos = tx;
    ypos = ty;
    wid = tw;
    hei = th;
    label = tlabel;
  }
  
  void draw(){
    //it is important that this comes first
    if(down&&over&&!mousePressed){
      clicked=true;
    }else{
      clicked=false;
    }
    
    //UP OVER AND DOWN STATE CONTROLS
    if(mouseX>xpos && mouseY>ypos && mouseX<xpos+wid && mouseY<ypos+hei){
      over=true;
      if(mousePressed){
        down=true;
      }else{
        down=false;
      }
    }else{
      over=false;down=false;
    }

    
    //box color controls
   
      if(!down){
        fill(127);
      }else{
        fill(0);
      }
    
    stroke(0);
    rect(xpos, ypos, wid, hei);//draws the rectangle, the last param is the round corners
    
    //Text Color Controls
    if(down){
      fill(255);
    }else{    
      fill(0);
    }
 
    text(label, 1+xpos+wid/2-(textWidth(label)/2), ypos+hei/2+(textAscent()/2)); 

  } 
}

THIS IS MY TRY WITH TOUCHES ARRAYS

class Button{
  int xpos, ypos, wid, hei;
  String label;
  boolean over = false;
  boolean down = false; 
  boolean clicked = false;
  Button(
  int tx, int ty,
  int tw, int th,
  String tlabel
  ){
    xpos = tx;
    ypos = ty;
    wid = tw;
    hei = th;
    label = tlabel;
  }
  
  void draw(){
    //it is important that this comes first
    for (int i = 0; i < touches.length; i++) {
    if(down&&over&&touches[0].area==0){
     
      clicked=true;
    }else{
      clicked=false;
    }
    
    
    //UP OVER AND DOWN STATE CONTROLS
    //if(mouseX>xpos && mouseY>ypos && mouseX<xpos+wid && mouseY<ypos+hei){
      if(touches[i].x>xpos && touches[i].y>ypos && touches[i].x<xpos+wid && touches[i].y<ypos+hei){
      over=true;
      if(touches[0].area==0){
        down=true;
      }else{
        down=false;
      }
    }else{
      over=false;down=false;
    }

    
    //box color controls
   
      if(!down){
        fill(127);
      }else{
        fill(0);
      }
    
    stroke(0);
    rect(xpos, ypos, wid, hei);//draws the rectangle, the last param is the round corners
    
    //Text Color Controls
    if(down){
      fill(255);
    }else{    
      fill(0);
    }
 
    text(label, 1+xpos+wid/2-(textWidth(label)/2), ypos+hei/2+(textAscent()/2)); 

  } 
  }
}
    

Thanks, i don’t need it any more, i archive it and understand that for my purpose i don’t need multi touch

Just to clarify, if you want to try multi touch, you should check this:

Tangani isyarat multisentuh  |  Developer Android  |  Android Developers

I suggest you install the Ketai library and explore the examples that it comes with. I don’t remember if they handle multi touch (it should). Nevertheless, it will give you a lead to work with gestures. You can also check their site, ketai.org

Kf