diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 6b7b16796..8c06f42da 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -1230,8 +1230,8 @@ public class PApplet extends Applet * redraw() causes the code inside draw() to execute once and * loop() will causes the code inside draw() to execute * continuously again. The number of times draw() executes in each - * second may be controlled with the delay() and frameRate() - * functions. There can only be one draw() function for each sketch + * second may be controlled with frameRate() function. + * There can only be one draw() function for each sketch * and draw() must exist if you want the code to run continuously or * to process events such as mousePressed(). Sometimes, you might * have an empty call to draw() in your program as shown in the @@ -1811,7 +1811,7 @@ public class PApplet extends Applet // render a single frame //handleDraw(); if (g != null) g.requestDraw(); - + if (frameCount == 1) { // Call the request focus event once the image is sure to be on // screen and the component is valid. The OpenGL renderer will @@ -2048,7 +2048,7 @@ public class PApplet extends Applet } } - + ////////////////////////////////////////////////////////////// @@ -2074,14 +2074,14 @@ public class PApplet extends Applet }); } - + public void removeListeners() { removeMouseListener(this); removeMouseMotionListener(this); removeKeyListener(this); removeFocusListener(this); -// removeComponentListener(??); +// removeComponentListener(??); // addComponentListener(new ComponentAdapter() { // public void componentResized(ComponentEvent e) { // Component c = e.getComponent(); @@ -2095,10 +2095,10 @@ public class PApplet extends Applet // redraw(); // } // } -// }); +// }); } - - + + public void addListeners(Canvas canvas) { canvas.addMouseListener(this); canvas.addMouseMotionListener(this); @@ -2118,10 +2118,10 @@ public class PApplet extends Applet // redraw(); // } // } -// }); +// }); } - - + + public void removeListeners(Canvas canvas) { canvas.removeMouseListener(this); canvas.removeMouseMotionListener(this); @@ -2805,6 +2805,32 @@ public class PApplet extends Applet // controlling time (playing god) + /** + * The delay() function causes the program to halt for a specified time. + * Delay times are specified in thousandths of a second. For example, + * running delay(3000) will stop the program for three seconds and + * delay(500) will stop the program for a half-second. + * + * The screen only updates when the end of draw() is reached, so delay() + * cannot be used to slow down drawing. For instance, you cannot use delay() + * to control the timing of an animation. + * + * The delay() function should only be used for pausing scripts (i.e. + * a script that needs to pause a few seconds before attempting a download, + * or a sketch that needs to wait a few milliseconds before reading from + * the serial port). + */ + public void delay(int napTime) { + //if (frameCount != 0) { + //if (napTime > 0) { + try { + Thread.sleep(napTime); + } catch (InterruptedException e) { } + //} + //} + } + + /** * ( begin auto-generated from frameRate.xml ) * @@ -2815,13 +2841,6 @@ public class PApplet extends Applet * rate within setup(). The default rate is 60 frames per second. * * ( end auto-generated ) - *