Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Question about ControlP5 library

$
0
0

Hello, I have questions about the ControlP5 library. Yesterday, I've found this library with a scrollable list example:

import controlP5.*;

import java.util.*;

String[] listItems = new String[5];

ControlP5 cp5;

void setup() {

  size(400, 400);

  surface.setResizable(true);

  listItems[0] = "5130";

  listItems[1] = "5131";

  listItems[2] = "5150";

  listItems[3] = "5170";

  listItems[4] = "9591";

  cp5 = new ControlP5(this);

  List l = Arrays.asList(listItems);

  /* add a ScrollableList, by default it behaves like a DropdownList */

  cp5.addScrollableList("dropdown")

     .setPosition(10, 10)

     .setSize(width-20, height-20)

     .setBarHeight(50)

     .setItemHeight(20)

     .addItems(l)

     .setType(ScrollableList.LIST) // currently supported DROPDOWN and LIST

;

}

void draw() {

  background(240);

}

void dropdown(int n) {

  CColor c = new CColor();

  c.setBackground(color(255,0,0));

  cp5.get(ScrollableList.class, "dropdown").getItem(n).put("color", c);

}

(I've removed some code from the example which was un-necessary for me) Now, I have this questions:

  1. How can I change the cp5.setSize in my loop? As you can see, the sketch size is resizable, but if I change the size of the program, the list size won't change.
  2. How can you set the colors of the list text? I have a very light background, so I need black text in my list. Is this possible?
  3. Is it possible to let the user also unselect items? In this example code, there is no option.

Thanks in advance, Daantje


Viewing all articles
Browse latest Browse all 2896

Trending Articles