FunctionGenBox boxes[] = new FunctionGenBox[4]; FunctionGenBox drag; void setup() { size(640,480); frameRate(30); for(int i=0; i= boxes[i].x && mouseX <= boxes[i].x + boxes[i].w && mouseY >= boxes[i].y && mouseY <= boxes[i].y + boxes[i].h) { drag = boxes[i]; break; } } }