Modify a text file: $/Button.pde
$/Button.pde
class Button { //// A button, displayed on screen, and able to detect when mouse is OVER. int x= 10; // Position and size of this button. int y= 10; int w= 100; int h= 50; color c; // Color of this button. int type=1; // Button type (1=rectangle) String name; // Text on this button. //// CONSTRUCTOR(S) //// Button( String s, int xset, int yset) { //Button(); //// Accept x & y coordinates; use default for the others. x= xset; y= yset; c=color(255,127,127); name=s; } Button( String s, int xset, int yset, int wset, int hset, int tset, color cset) { //Button(); //// Accept x & y coordinates; use default for the others. x= xset; y= yset; w= wset; h= hset; c= cset; type= tset; name=s; } //// METHODS() //// void show() { //// Show the button. fill(c); if (type<1) { ellipseMode(CORNER); ellipse(x,y,w,h); }else{ rectMode(CORNER); rect(x,y,w,h); } // Name on button. fill(0); text( name, x+10, y+h/2 ); } boolean isOver( int xx, int yy ) { //// Return true if xx,yy is over this button! if (xx < x) return false; else if (xx > x+w) return false; else if (yy < y) return false; else if (yy > y+h) return false; return true; //OR: return ( xx>x && xx
y && yy