fix listener add/remove issue

This commit is contained in:
benfry
2012-04-05 20:10:42 +00:00
parent e849ab8ee5
commit bb760a1969
2 changed files with 12 additions and 2 deletions
+11 -1
View File
@@ -2114,8 +2114,18 @@ public class PApplet extends Applet
comp.removeMouseMotionListener(this);
comp.removeKeyListener(this);
comp.removeFocusListener(this);
}
/**
* Call to remove, then add, listeners to a component.
* Avoids issues with double-adding.
*/
public void updateListeners(Component comp) {
removeListeners(comp);
addListeners(comp);
}
//////////////////////////////////////////////////////////////
@@ -139,7 +139,7 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ {
// parent.addListeners(canvas);
//// canvas.createBufferStrategy(1);
// g2 = (Graphics2D) canvas.getGraphics();
parent.addListeners(parent);
parent.updateListeners(parent); // in case they're already there
// Needs to be RGB otherwise there's a major performance hit [0204]
// http://code.google.com/p/processing/issues/detail?id=729