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 › draw different waveform in different tab's
Page Index Toggle Pages: 1
draw different waveform in different tab's (Read 2461 times)
draw different waveform in different tab's
Oct 22nd, 2009, 12:22pm
 
hallo Andreas,

benutze ControlP5 und würde gerne verschiedene Waveform's in verschiedenen Tab's darstellen.

wie kann ich einer IF(){}ELSE{} abfragen welcher Tab gerade aktiv ist??

hab schon versucht den Namen des Tab's und die ID abzufragen. ich bekomme aber immer ein "nullpointer exception".



mfg maik
Re: draw different waveform in different tab's
Reply #1 - Oct 22nd, 2009, 1:10pm
 
Auch wenn Andreas dich versteht, sind die Chancen dass du Hilfe bekommst sicher besser wenn du in english fragst. So wäre es am Ende auch für andere nützlich. Kann dir leider nicht weiterhelfen
Re: draw different waveform in different tab's
Reply #2 - Oct 23rd, 2009, 1:36am
 
hi there,
the question here is how can one identify the current active controlP5 tab within a sketch. since controlP5 can display controllers in multiple windows, you would need to tell controlP5 which window to use (use function controlP5.window(this) to get access to the main window). now you can access the current tab by using controlP5.window(this).currentTab()

if you did assign IDs to your tabs before, you can use the following code snippet inside draw()

Code:


 int ctid = controlP5.window(this).currentTab().id();

 if(ctid == 1) {
   fill(255,0,0);
   rect(40,40,100,100);
 } else if (ctid==2) {
   fill(0,255,0);
   rect(100,100,200,20);
 }



hope this helps.
best,
andreas

Re: draw different waveform in different tab's
Reply #3 - Oct 23rd, 2009, 1:47am
 
WOW Shocked

that work's perfekt!!!

ok next question  Wink
how can i display the tabs with different color's?? i tired

Code:
controlP5.setColorActive(color(128,0,128));

after every Tab in setup(), but only the last take's effekt Undecided

can't find any example, were this was tried befor.

mfg maik
Re: draw different waveform in different tab's
Reply #4 - Oct 23rd, 2009, 2:12am
 
OMG

real big problem Sad

can't use
Code:
  Controller msecMax = controlP5.addSlider("msecMax",100,200,150,21,17,width-22,19); 


error->" the type Controller is ambiguous"
it's only when i use Code:
import ddf.minim.*; 

in the sketch.
but i need minim Wink

how to get slider to cintrollerWindow??

mfg maik
Re: draw different waveform in different tab's
Reply #5 - Oct 23rd, 2009, 5:09am
 
hi,
there is a conflict with identifying class Controller since both minim and controlP5 use a class called Controller. but you can use
Code:

Slider msecMax = controlP5.addSlider("msecMax",100,200,150,21,17,width-22,19);

or
Code:

controlP5.Controller msecMax = controlP5.addSlider("msecMax",100,200,150,21,17,width-22,19);


Re: draw different waveform in different tab's
Reply #6 - Oct 23rd, 2009, 9:08am
 
thanx  Cool

anybody should change this Roll Eyes

next question  Wink
setup of controlWindow
Code:
controlWindow = controlP5.addControlWindow("Settings",100,100,400,400);
controlWindow.setBackground(color(40));


i've added a multilist to controlWindow, and set an id for each MultiListButton.
Code:
 MultiList l = controlP5.addMultiList("myList",0,10,width/2,12);
 l.setWindow(controlWindow);
   MultiListButton b = l.add("Midi Outputs",2);
for(int i=0;i<midiIO.numberOfOutputDevices();i++) {
   MultiListButton d = b.add("Midi Output",40+i+1);
   d.setLabel((i+1)+" "+midiIO.getOutputDeviceName(i));
   d.setId(i);
   
 }

now i will get the id of each MultiListButton like
Code:
int ctid = controlP5.window(this).currentTab().id(); 


i've tried this
Code:
int lsid = controlP5.window("Settings").MultiListButton.id(); 


but it don't work  Roll Eyes
how can i get the id of the MultiListButton's in controlWindow??

regards maik
Re: draw different waveform in different tab's
Reply #7 - Oct 23rd, 2009, 2:02pm
 
update

i've tried something  Roll Eyes

that work's, but i get all id's . i only whant the id's of the MultiListButton's
Code:
lsid = theEvent.controller().id(); 



regards maik
Re: draw different waveform in different tab's
Reply #8 - Nov 8th, 2009, 7:47am
 
hi,

did anyone know's how i can get the id's of the Multilist??

regards maik
Re: draw different waveform in different tab's
Reply #9 - Nov 9th, 2009, 8:40am
 
hi, a multilist triggers 2 events. 1 for the multilist itself and 1 for the multilistbutton that has been pressed.
Code:

void controlEvent(ControlEvent theEvent) {
 println(theEvent.controller().name()+" = "+theEvent.value()+" / "+theEvent.controller().id());  
}

the above code prints 2 events, the first one for the multilist, the second one for the multilistbutton.

to check the id for a multilist use
Code:

void controlEvent(ControlEvent theEvent) {
 if(theEvent.controller() instanceof MultiList) {
   println("a multilist event. id:"+theEvent.controller().id());
 }
}

which gives you the id of the multilist. is this what you are looking for?

Re: draw different waveform in different tab's
Reply #10 - Nov 22nd, 2009, 6:07am
 
@ sojamo

that's what i needed.
thank you very, very, very much Grin

with this code, i can get the id's of the multilistbutton's !!!!
Code:
 if(theEvent.controller() instanceof MultiListButton) {
   println("a multilist event. id:"+theEvent.controller().id());
 }



regards maik
Page Index Toggle Pages: 1