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 & HelpSyntax Questions › ControlP5 Question
Page Index Toggle Pages: 1
ControlP5 Question (Read 282 times)
ControlP5 Question
Dec 3rd, 2008, 10:01pm
 
i have a question about the behavior of the setAutoDraw() method in ControlP5.  it seems to me that the following code should not draw the slider until a key is pressed, yet the slider is drawn, and the program runs exactly the same with or without the setAutoDraw() method:

import controlP5.*;
ControlP5 controlP5;
int myColorBackground = color(0,0,0);

void setup() {
 size(400,400);
 controlP5 = new ControlP5(this);
 controlP5.addSlider("slider",100,200,128,100,160,100,10);
 controlP5.setAutoDraw(false);
}

void draw() {
 background(myColorBackground);
}

void slider(int theColor) {
 myColorBackground = color(theColor);
}

void keyPressed()
{
 controlP5.draw();
 println("key pressed");
}
Re: ControlP5 Question
Reply #1 - Dec 8th, 2008, 10:47pm
 
I noticed this, too. I think it's a bug. I used to use setAutoDraw(false) to hide the GUI, only displaying it under certain circumstances. But now I don't think it has any effect.

You can emulate it by hiding/showing the underlying ControlWindow, with something like

 controlP5.controlWindow.hide(); //GUI will not be shown or active

and

 controlP5.controlWindow.show(); //GUI will be drawn and active

But that requires a different sequence of control, as it doesn't allow you to draw the GUI on command (when not hidden, it will always be drawn at the end of your draw() function).
Re: ControlP5 Question
Reply #2 - Dec 9th, 2008, 3:47am
 
thanks andy, this was a little bug, thanks for pointing this out. fixed now with 0.3.6
a small example using setAutoDraw() and isAutoDraw()
Quote:
import controlP5.*;

ControlP5 controlP5;

void setup() {
 size(400,400);
 controlP5 = new ControlP5(this);
 controlP5.setAutoDraw(false);
controlP5.addSlider("slider",100,167,128,100,160,10,100);
controlP5.addSlider("sliderValue",-10000,2550,12,200,200,10,100);
}

void draw() {
 background(0);
}

void keyPressed() {
 if(key==' ') {
   controlP5.setAutoDraw(!controlP5.isAutoDraw());
 }
}
Page Index Toggle Pages: 1