ControlP5: duplicate controlEvent

edited June 2014 in Library Questions

Hi guys! I have this message because i don't know how put a color picker and two buttons in my sketch. How maintain both?

  void controlEvent(ControlEvent Button)
  if (Button.controller().name()=="Shot") {
      background(0); //screenshot
  if (Button.controller().name()=="Clear") {
      background(0); //clear screen

public void controlEvent(ControlEvent c)
  // when a value change from a ColorPicker is received, extract the ARGB values
  // from the controller's array value
  if(c.isFrom(cp)) {
    int r = int(c.getArrayValue(0));
    int g = int(c.getArrayValue(1));
    int b = int(c.getArrayValue(2));
    int a = int(c.getArrayValue(3));
    color col = color(r,g,b,a);

// color information from ColorPicker 'picker' are forwarded to the picker(int) function
void picker(int col) {


  • This is not a runnable code example. There are many ways to identify controllers and controlEvents in the controlEvent method. One way given your current controlEvent... remove the Button controlEvent, add a global instance of the buttons and add some else if for different controllers besides the cp. As in: else if (c.isFrom(buttonOne)) {

Sign In or Register to comment.