ControlP5 Draw over a Button

edited February 2016 in Library Questions

I try to use a messagebox if the mouse over some elements. But the Elements of cp5 are every time in foreground. How can I draw a rect over the buttons?

See like this:

import controlP5.*;

ControlP5 cp5;

void setup() {
  size(400, 600);
  cp5 = new ControlP5(this);
  cp5.addButton("A")
    .setValue(0)
    .setPosition(100, 100)
    .setSize(200, 19)
    ;
}

void draw() {
  background(120);
  rect(mouseX, mouseY, 40, 100);
}
Tagged:

Answers

  • edited February 2016

    Find a solution:

    controlP5 / ControlP5 / setAutoDraw( )

    name setAutoDraw ( )

    description by default controlP5 draws any controller on top of any drawing done in the draw() function (this doesnt apply to P3D where controlP5.draw() has to be called manually in the sketch's draw() function ). to turn off the auto drawing of controlP5, use controlP5.setAutoDraw(false). now you can call controlP5.draw() any time whenever controllers should be drawn into the sketch.

    @andreas.schlegel: awesome libary! i can do everything :)

  • import controlP5.*;
    
    ControlP5 cp5;
    
    void setup() { 
    size(400, 600); cp5 = new ControlP5(this); 
    cp5.addButton("A") .setValue(0) .setPosition(100, 100) .setSize(200, 19) ;
    cp5.setAutoDraw(false); 
    }
    
    void draw() { 
    background(120); 
    cp5.draw();
    rect(mouseX, mouseY, 40, 100); 
    }
    
    
Sign In or Register to comment.