We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › ControlP5 two listboxes
Page Index Toggle Pages: 1
ControlP5 two listboxes (Read 1203 times)
ControlP5 two listboxes
Apr 13th, 2010, 12:41pm
 
Hi, I am new to Processing and I really like it!

I am playing with the examples from Fry's book and trying some libraries too.  I need some help here.  I am trying ControlP5 and added two listboxes.  I found that I could not distinguish events from the two listboxes.  I used the piece of codes from ControlP5 example
  if (theEvent.isGroup()) ...
but of course this does not distinguish between the two listboxes.

I added group ids to the boxes but it was not working.

Any tip is appreciated!

Thanks,
max
Re: ControlP5 two listboxes
Reply #1 - Apr 14th, 2010, 4:35am
 
the following works for me:
create 2 listBoxes (in setup)
Code:

 ListBox l1 = controlP5.addListBox("myList1",100,100,120,120);
 l1.setId(1);
 ListBox l2 = controlP5.addListBox("myList2",240,100,120,120);
 l2.setId(2);
 for(int i=0;i<80;i++) {
   l1.addItem("item "+i,i);
   l2.addItem("item "+i,i);
 }

check the id of a listBox inside controlEvent()
Code:

void controlEvent(ControlEvent theEvent) {
 if (theEvent.isGroup()) {
   println(theEvent.group().id());
 }
}

prints 1 for the first listBox and 2 for the second.
does that work for you?

Re: ControlP5 two listboxes
Reply #2 - Apr 16th, 2010, 3:26am
 
Thanks a lot, sojamo!

I actually tried using id but I must have made some mistakes so it didn't work, but your solution does!!
(and you can see that I am not a programmer...)

BTW, thanks for the ControlP5 library!  REALLY love it!!
Page Index Toggle Pages: 1