We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › change button position in ControlP5
Page Index Toggle Pages: 1
change button position in ControlP5 (Read 542 times)
change button position in ControlP5
Nov 16th, 2009, 3:07pm
 
hi,

Does somebody know how to change the positions of buttons in ControlP5 after the buttons are set up.
I have tried this bit of code but it doesn't work and i don't know why.
Thanks.

ControlP5 controlP5;
controlP5.Button tower, tryOwn, about, makeUp;

int colorActive =100;
int greyLight = 0;
int buttonPosX ;
int buttonPoxY;

void setup()
{
 size(500, 500);
 buttonPosX =5;   ///marginXleft+500+65;
buttonPoxY = height -60;

 controlP5 = new ControlP5(this);
 controlP5.Button tower  = controlP5.addButton("Load a Story",1,buttonPosX,buttonPoxY,80,20);
 tower.setColorBackground(greyLight);
 tower.setColorActive(colorActive);
 tower.setId(100);

 controlP5.Button tryOwn  = controlP5.addButton("Type Words",2,buttonPosX+90,buttonPoxY,80,20);
 tryOwn.setColorBackground(greyLight);
 tryOwn.setColorActive(colorActive);
 tryOwn.setId(200);  

 controlP5.Button about  = controlP5.addButton("Background",3,buttonPosX+(90*2),buttonPoxY,80,20);
 about.setColorBackground(greyLight);
 //about.setColorForeground (grey );
 about.setColorActive(colorActive);
 about.setId(300);  

 controlP5.Button makeUp  = controlP5.addButton("About the Visual",4,buttonPosX+(90*3),buttonPoxY,85,20);
 makeUp.setColorBackground(greyLight);
 makeUp.setColorActive(colorActive);
 makeUp.setId(400);  
 
 
}
void controlEvent(ControlEvent theEvent)
{
 //MAIN NAV BUTTONS
if( theEvent.controller().id() == 100)
 {
   println("controller : "+theEvent.controller().id());
   moveButtons();
 }
 else if( theEvent.controller().id() == 200)
 {
   println("controller : "+theEvent.controller().id());
  moveButtons();
 }
 else if( theEvent.controller().id() == 300)
 {
   println("controller : "+theEvent.controller().id());
  moveButtons();
 }
 else if( theEvent.controller().id() == 400)
 {
   println("controller : "+theEvent.controller().id());
   moveButtons();

 }
}

void moveButtons()
{
// buttonPosX =100;  
// buttonPoxY = height -60;
// tower.setPosition(buttonPosX, buttonPoxY);  
 
 tower.position().x = 10;
 tower.position().y = 10;
}
Page Index Toggle Pages: 1