kumar
YaBB Newbies
Offline
Posts: 19
Re: controlP5
Reply #242 - May 17th , 2010, 12:34pm
Hi Sojamo, Thanks for your contribution and help to resolve doubts in ControlP5 and I have a doubt in List box usage, If you can help me It would really help for my project and What my query is.. I would like to use List box in my application so that I have added list box code and named 12 months like Jan,Feb..,Dec. but I added the values in the form of key value pairs. So once I selected month from List I got only the value of the month only How should i get the Name of the month like "Jan"/"Feb" that values needed for me further implementation of code. I know its a small question but I am not much aware about processing language advance thanks for your help.. I am giving sample code which I am unable to retrive the selected month.. how should I get month values in void draw() method. import controlP5.*; ControlP5 controlP5; ListBox l; int cnt = 0; PImage mapImage; Table locationTable; int rowCount; color bg = color(255); public void setup( ) { size(640, 400); // list box start frameRate(30); controlP5 = new ControlP5(this); l = controlP5.addListBox("myList",10,10,100,100); l.setItemHeight(10); l.setBarHeight(10); l.captionLabel().toUpperCase(true); l.captionLabel().set("Select Month"); l.captionLabel().style().marginTop = 3; l.valueLabel().style().marginTop = 3; // the +/- sign //l.setBackgroundColor(color(100,0,0)); // for(int i=0;i<12;i++) { // if(i==0){ // l.addItem("Jan",0); //} l.addItem("Jan",0); l.addItem("Feb",1); l.addItem("Mar",2); l.addItem("Apr",3); l.addItem("May",4); l.addItem("Jun",5); l.addItem("Jul",6); l.addItem("Aug",7); l.addItem("Sep",8); l.addItem("Oct",9); l.addItem("Nov",10); l.addItem("Dec",11); // } l.setColorBackground(color(30,128)); l.setColorActive(color(0,0,30,128)); // list box end mapImage = loadImage("ireland.png"); // Make a data table from a file that contains // the coordinates of each state. locationTable = new Table("irelanddata.tsv"); // The row count will be used a lot, so store it globally. rowCount = locationTable.getRowCount( ); PFont font = loadFont("Arial-BoldMT-16.vlw"); textFont(font); } void controlEvent(ControlEvent theEvent) { // ListBox is if type ControlGroup. // 1 controlEvent will be executed, where the event // originates from a ControlGroup. therefore // you need to check the Event with // if (theEvent.isGroup()) // to avoid an error message from controlP5. if (theEvent.isGroup()) { // an event from a group e.g. scrollList println(theEvent.group().value()+" from "+theEvent.group()); println(theEvent.group()); } }