Thanks for the links. I need 2 sketches because using background(0) to clear the screen clears the entire screen, even the buttons area that don't require clearing. It can also cause flickering when there are a lot of things to redraw.
But if I use one sketch to handle the output/display area, and the other to handle the actions/buttons area, and a 3rd sketch to control them, I can clear just the drawing area only or just the buttons area only with background(0) because both are independent of each other(with their own setup(), draw(), etc.).
PhiLho wrote on Aug 18th, 2009, 2:17am:Several ways, like getting the parent of your class, etc. but the simpler way might be to pass the PApplet instance reference to your class, like you do for library class constructors.
Do you mean something like
Code:class1(PApplet p){} //constructor
and then doing
Code:class1 c = new class(this);
That looks like it would work.
While searching the forums, I found this library that does exactly what I need.
http://www.soi.city.ac.uk/~jwo/processing/multiWindow/index.html
There are 2 ways I can think of to do this. 2 embedded sketches running in 1 window. Or 2 classes controlled by 1 sketch. They are not the same thing.
With
2 sketches, if I do background(0) in one, the other will not be affected. Also, 2 sketches means 2 drawing canvas/coordinate systems, making things a lot easier when deciding where to add buttons.
With
2 classes, doing background(0) will clear the entire thing.
That library works great, but I still can't use "this". Is there any way to get the PApplet in the current sketch besides using "this"?