[controlP5] attach many controller to one tab ???!!

edited August 2014 in Library Questions

Hello, i need your help:

i have 4 tabs. And the first and second tab contains many many controllers.

import controlP5.*;

ControlP5 cp5 = new ControlP5(this);
cp5.addTab("tab2");
cp5.addButton("buttonB").moveTo("tab2");
cp5.addButton("buttonC").moveTo("tab2");  //>>problem: moveTo("tab2") appears very often

my idea/wish: to create "cp6" for the many controllers (for tab2) and attach it to the tab2 from cp5.

import controlP5.*;

ControlP5 cp5 = new ControlP5(this);
ControlP5 cp6 = new ControlP5(this);

cp5.addTab("tab2");

cp6.addButton("buttonB");
cp6.addButton("buttonC");
[...]

cp6.moveTo(cp5.getTab("tab2"));  //>>but this doesn't work. ..unfortunately
Tagged:

Answers

  • problem: moveTo("tab2") appears very often

    How is this a problem?

  • How is this a problem?

    It is not very professional. Besides i have many work.

  • Do you mean the repetition of similar code? You can apply the same style including moving to another tab via a method. Then you just send controllers through that method to get styled, placed, etc.

    Code Example

    void organise(String theControllerName, String tabName) {
      Controller c = cp5.getController(theControllerName);
      // and many other stylings, placement, etc.
      c.moveTo(tabName);
    }
    
  • edited August 2014

    Do you mean the repetition of similar code? yes

    your code example is little similar to this http://www.sojamo.de/libraries/controlP5/examples/extra/ControlP5style/ControlP5style.pde or not? ;)
    ..with it, it will be better. (but not perfect for me) B-)

  • Yes, it is similar indeed (always smart to check out the examples) ;-)

    But with that technique you can do a lot more stuff than the little example shows...

Sign In or Register to comment.