text() and link() functions in a class
in
Programming Questions
•
2 years ago
Hi,
I want to create a class for buttons but don't know how to implement text() and link() functions:
Button myButton1;
void setup(){
size(300,300);
myButton1=new Button(100,100,40,20); // <-text() and link() function inside?
}
void draw(){
myButton1.display();
}
class Button{
int posx;
int posy;
int sizex;
int sizey;
Button(int tempposx,int tempposy,int tempsizex,int tempsizey){
posx=tempposx;
posy=tempposy;
sizex=tempsizex;
sizey=tempsizey;
}
void display(){
fill(100);
rect(posx,posy,sizex,sizey);
}
}
The idea is that every button could have it's own text displayed in the box (like 'Links' or 'Email' ) and a link. Any help would be appreciated!
I want to create a class for buttons but don't know how to implement text() and link() functions:
Button myButton1;
void setup(){
size(300,300);
myButton1=new Button(100,100,40,20); // <-text() and link() function inside?
}
void draw(){
myButton1.display();
}
class Button{
int posx;
int posy;
int sizex;
int sizey;
Button(int tempposx,int tempposy,int tempsizex,int tempsizey){
posx=tempposx;
posy=tempposy;
sizex=tempsizex;
sizey=tempsizey;
}
void display(){
fill(100);
rect(posx,posy,sizex,sizey);
}
}
The idea is that every button could have it's own text displayed in the box (like 'Links' or 'Email' ) and a link. Any help would be appreciated!
2