ControlP5 and DropdownList Problem
in
Contributed Library Questions
•
6 months ago
There are already some questions arround cp5 and Lists but i was not able to solve "my" problem so far. Maybe someone out there knows a solution - would be great.
In my Program there are some images and lines plus some cp5 elements which woorks fine so far. But if i want to ad a cp5 ListItem, it won't work properly until i set the background to some int value in the draw function. e.g -> background(128); As soon as i set the background to some value, the List works fine but all the other elements disapear.
I have Processing 2.0b8 installed but i'm using the Sublime Text 2 IDE.
Here is the Code. I'ts more or less taken from the cp5 example. I deleted most of the comments in order to limit the list.
Thank you for the help and sorry for my english.
In my Program there are some images and lines plus some cp5 elements which woorks fine so far. But if i want to ad a cp5 ListItem, it won't work properly until i set the background to some int value in the draw function. e.g -> background(128); As soon as i set the background to some value, the List works fine but all the other elements disapear.
I have Processing 2.0b8 installed but i'm using the Sublime Text 2 IDE.
Here is the Code. I'ts more or less taken from the cp5 example. I deleted most of the comments in order to limit the list.
Thank you for the help and sorry for my english.
- import controlP5.*;
- ControlP5 cp5;
- DropdownList d1;
- int cnt = 0;
- PImage appHeader;
- PImage device;
- void setup() {
- size(1000, 830, P3D);
- cp5 = new ControlP5(this);
- // create a DropdownList
- d1 = cp5.addDropdownList("myList-d1")
- .setPosition(100, 100)
- ;
- customize(d1); // customize the first list
- // --------------- GUI OBEN ------------------
- appHeader = loadImage("header.png");
- image(appHeader, 0, 0); // position des headers
- // --------------- DEVICE ------------------
- device = loadImage("device.png");
- image(device, 70, 140); // position of device
- }
- void customize(DropdownList ddl) {
- // a convenience function to customize a DropdownList
- ddl.setBackgroundColor(color(190));
- ddl.setItemHeight(20);
- ddl.setBarHeight(15);
- ddl.captionLabel().set("HTC One X");
- ddl.captionLabel().style().marginTop = 3;
- ddl.captionLabel().style().marginLeft = 3;
- ddl.valueLabel().style().marginTop = 3;
- ddl.addItem("Samsung Galaxy S4", 0);
- ddl.addItem("Google Nexus 4 ", 1);
- //ddl.scroll(0);
- ddl.setColorBackground(color(60));
- ddl.setColorActive(color(255, 128));
- }
- void controlEvent(ControlEvent theEvent) {
- if (theEvent.isGroup()) {
- // check if the Event was triggered from a ControlGroup
- println("event from group : "+theEvent.getGroup().getValue()+" from "+theEvent.getGroup());
- }
- else if (theEvent.isController()) {
- println("event from controller : "+theEvent.getController().getValue()+" from "+theEvent.getController());
- }
- }
- void draw() {
- }
1