We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is there a simple example on how to run code when the G4P main window is closing ?
This will create a new window when you close it with the red X if will execute the method windowCloseMethod.
windowCloseMethod
The code inside exit will execute when the main window closes but this does not require G4P, it is just Processing/Java
exit
import g4p_controls.*; GWindow window; void setup() { size(300, 300); window = GWindow.getWindow(this, "My Window", 100, 50, 480, 320, JAVA2D); window.addDrawHandler(this, "windowDraw"); window.setActionOnClose(G4P.CLOSE_WINDOW); window.addOnCloseHandler(this, "windowCloseMethod"); } void draw() { background(200, 200, 255); // blue } void windowDraw(PApplet app, GWinData data) { app.background(255); // white app.strokeWeight(2); // draw black line to current mouse position app.stroke(0); app.line(app.width / 2, app.height/2, app.mouseX, app.mouseY); } void windowCloseMethod(PApplet applet, GWinData windata) { println("======================================================="); println("========== WINDOW CLOSING ============================="); println("======================================================="); window = null; // clear reference } void exit() { println("======================================================="); println("========== MAIN WINDOW CLOSING ========================"); println("======================================================="); }
Thank you Sir for the fast reply. Your library and tools are awesome.....thank you for making it available.
Answers
This will create a new window when you close it with the red X if will execute the method
windowCloseMethod
.The code inside
exit
will execute when the main window closes but this does not require G4P, it is just Processing/JavaThank you Sir for the fast reply. Your library and tools are awesome.....thank you for making it available.