# Function onTap, KetaiGesture in Processing for Android

**URL:** <https://discourse.processing.org/t/function-ontap-ketaigesture-in-processing-for-android/35340>\
**Category:** Processing for Android\
**Created:** [February 20, 2022, 4:23pm UTC](https://discourse.processing.org/t/function-ontap-ketaigesture-in-processing-for-android/35340 "2022-02-20T16:23:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TiagoNess](https://avatars.discourse-cdn.com/v4/letter/t/a4c791/32.png) [@TiagoNess](https://discourse.processing.org/u/TiagoNess)\
**Post date:** [February 20, 2022, 4:23pm UTC](https://discourse.processing.org/t/function-ontap-ketaigesture-in-processing-for-android/35340/1 "2022-02-20T16:23:22Z")

</div>

Hello everyone, I have a concern, I am trying to do the following: create objects with a tap on the device, but when counting the objects, the onTap function seems to create twice as many objects.

The principal:

```auto
import android.view.MotionEvent;
import ketai.ui.*;

KetaiGesture gesture;
ArrayList<Modulo> mds = new ArrayList<Modulo>();
int diam;

void setup() {
  fullScreen();
  orientation(PORTRAIT);
  
  gesture = new KetaiGesture(this);
  textSize(80);
  diam = 100;
  Modulo m1 = new Modulo(1,10,100);
  Modulo m2 = new Modulo(2,50,100);
  Modulo m3 = new Modulo(3,100,100);
  mds.add(m1);
  mds.add(m2);
  mds.add(m3);
       text(mds.size(),350,200);
}
 
void draw() {
  background(0,255,0);
  
  if (mds.size()>0){
    for (int i= mds.size()-1; i>=0; i--) {
      Modulo s = mds.get(i);
      if (s.isActiva()==false) {
        mds.remove(s);
        
      } else {
        s.display();
        text(mds.size(),100,250);
      }
    }
  }
}

void onTap(float x, float y) {
  //agrega dos objetos?? :c  
   mds.add(new Modulo(mds.size(), x, y));
}

void mousePressed() {
  
}
void mouseDragged() {
}

public boolean surfaceTouchEvent (MotionEvent event) {
  super.surfaceTouchEvent(event);
  return gesture.surfaceTouchEvent(event);
}

```

The modulo:

```auto
class Modulo{
  PVector pos;
  int id;
  boolean activa;
  
  
  Modulo(int id_,float x, float y){
    id=id_;
    pos = new PVector (x,y);
    activa = true;
    
  }
  
  void setActiva(boolean activa_){
     activa = activa_;
  }
  
  void update(){
    pos.x = mouseX;
    pos.y = mouseY;
  }
  
  void display(){
    pushStyle();
    stroke(245,0,0);
    fill(255,0,0);
    ellipse(pos.x,pos.y,diam,diam);
    popStyle();
    text(id,pos.x,pos.y);
  }
  
  boolean isActiva(){
    return activa;
  }
  
  boolean over () {
    if (dist(mouseX, mouseY, pos.x, pos.y) < diam/2) {
      return true;
    } else {
      return false;
    }
  }
  void mouseDragged(){
    if (dist(mouseX, mouseY, pos.x, pos.y) > diam/2)
      return; // 
      update();
  }
  
  void mousePressed(){
    if (dist(mouseX, mouseY, pos.x, pos.y) > diam/2)
      return;
      update();
  }
}

```

Is there a way to create a single object with the onTap function?
