controlP5 problem.

edited July 2018 in Library Questions


I`ve a problem with controlP5 library. In a json file i stored the value of a variable of a class name "layer", witch is equal to buttonBar choice.

buttonBar = layer

Next, i want to load that value, but i cant make that buttonBar set the value and display on... the same is happening with a listBox.

but no with sliders: this works perfectly. (t2) is a slider.

      float T2 = shader.getFloat("t2"); // value load from  JSON file

but this not:

    int n = numberLayer.getInt("numberLayer");
    shaderWin.cpp5.getController("l").setValue(n); // "l"  is a buttonBar. i want the item number N on.

      .setPosition(0, 0)
      //.setSize(1000, 20)
      .addItems(split("0 1 2 3 4 5 6 7 8", " "))

  void l(int n) {
    println("bar clicked, item-value:", n);
    layer.layer = n;

anybody know why?


  • There is a new forum

    Please ask there

  • I didn't test your code not I attempt running it. First, you should avoid naming your controllers as just numbers. It is not a good practice in short. I also suggest to try shaderWin.cpp5.getController("l").setValue(float(n)); as it seems the first setter was working for you.

    Finally, where are you setting this value? Are you doing it either in setup, draw, any of controlP5 callback functions or any other function that are called inside any of the aforementioned functions? In other words, you are not calling your setter in a global scope, right? I have to ask as this is not clear in your post.


Sign In or Register to comment.