We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm trying to set up a G4P GUI so that when I click a button, it calls the draw() method from the sketch class. So far I have this where Prototype_CA contains the draw() method:
Prototype_CA pca;
public void button1_click1(GButton source, GEvent event) { //_CODE_:button1:844906:
println("button1 - GButton event occured " + System.currentTimeMillis()%10000000 );
background(255);
pca.draw();
}
Thanks.
Answers
Invoking draw() directly doesn't update canvas! [-X
You may try redraw() out though!
I wrote a method to reset the canvas to how it was before drawing and it seemed to work, thanks.
Just spotted this topic.
@GoToLoop is correct in that you should never call the main sketch draw() method directly, and even if you did it wouldn't make any difference because draw() is executed about 60 times a second anyway.
What is not clear are the statements
Prototype_CA pca;
pca.draw();
The first one would indicate that either
the sketch is called Prototype_CA
or you have created a class called Prototype_CA
which is it? :-/
Whichever it is you have not assigned a value to
pca
so it will be assigned the valuenull
which means the second statement would cause the sketch to crash.