Loading...
Logo
Processing Forum
I haven't found a main control p5- thread, so I write it here..
 
the title says almost everything.. can i change mouseover-color, font size, the font of a button with control p5? and how can I change it for all the buttons, how just for one?

Replies(2)

hi, the following snippet uses a custom function to build a button with custom mouseover-background, font, etc. hope this gives you a direction to what you are looking for. best, andreas

Copy code
  1. import controlP5.*;

  2. ControlP5 controlP5;

  3. void setup() {
  4.   size(640,480);
  5.   smooth();
  6.   frameRate(30);
  7.   controlP5 = new ControlP5(this);  
  8.   ControlFont cf1 = new ControlFont(createFont("Arial",20));
  9.   ControlFont cf2 = new ControlFont(createFont("Times",12));
  10.   createButton("hello",10,200,100,color(255,0,0),cf1);
  11.   createButton("world",10,200,140,color(255,128,0),cf2);
  12. }


  13. Button createButton(String theName, int theValue, int theX, int theY, color theColor, ControlFont theFont) {
  14.   Button b = controlP5.addButton(theName,theValue,theX,theY,120,39);
  15.   b.setColorActive(theColor); // color for mouse-over
  16.   b.setColorBackground(color(90)); // default color
  17.   b.captionLabel().setControlFont(theFont);
  18.   return b;
  19. }


  20. void draw() {
  21.   background(0);
  22. }

andreas schlegel, http://www.sojamo.de

thanks. that helped a lot.. really..

but what about changing the font color?

and changing the capital letters?

is this possible or do I have to take something else..?

and what about "deleting" buttons or setting buttons invisible?

thanks..