Menu of Buttons
Composition: A Menu Has Button Objects
ButtonGroup Version 1:
class ButtonGroup{
Button btn1, btn2, btn3;
Menu( Button _btn1, Button _btn2, Button _btn3){
btn1 = _btn1;
btn2 = _btn2;
btn3 = _btn3;
}
void display(){
btn1.display();
btn2.display();
btn3.display();
}
//this isn't working correctly, each button functions independently
void click(int mx, int my){
btn1.clicked(mx, my);
btn2.clicked(mx, my);
btn3.clicked(mx, my);
}
} //end class
////main tab
//Global Variable Declaration
int someVal; //we declare the type: int, then the name someVal
Button myButton; //we declare the type: Button, then the name: myButton
Button myButton2;
Button myButton3;
Menu myMenu;
//initialization
void setup(){
size(400,400);
someVal=5; //we initialize the int variable
myButton = new Button(); //for objects, we must call the constructor method
myButton2= new Button(0,100,50,50); // use Constructor with arguments
myButton3= new Button(0,200,50,50);
myMenu = new Menu( myButton, myButton2, myButton3 );
}
void draw(){
myMenu.display();
}
void mouseClicked(){
myMenu.clicked(mouseX, mouseY);
}Menu Buttons Finite State Machine

ActiveButton variable: FSM Memory
Menu Click Method()
Button1 Click()
Last updated