diff --git a/android/core/src/processing/core/PApplet.java b/android/core/src/processing/core/PApplet.java index 327bd0954..a69983eca 100644 --- a/android/core/src/processing/core/PApplet.java +++ b/android/core/src/processing/core/PApplet.java @@ -242,7 +242,7 @@ public class PApplet extends Activity implements PConstants, Runnable { public boolean mousePressed; - public MouseEvent mouseEvent; +// public MouseEvent mouseEvent; // public MotionEvent motionEvent; @@ -274,7 +274,7 @@ public class PApplet extends Activity implements PConstants, Runnable { /** * the last KeyEvent object passed into a mouse function. */ - public KeyEvent keyEvent; +// public KeyEvent keyEvent; /** * Gets set to true/false as the applet gains/loses focus. @@ -2139,7 +2139,7 @@ public class PApplet extends Activity implements PConstants, Runnable { protected void handleMouseEvent(MouseEvent event) { - mouseEvent = event; +// mouseEvent = event; // http://dev.processing.org/bugs/show_bug.cgi?id=170 // also prevents mouseExited() on the mac from hosing the mouse @@ -2206,25 +2206,25 @@ public class PApplet extends Activity implements PConstants, Runnable { switch (event.getAction()) { case MouseEvent.PRESS: - mousePressed(); + mousePressed(event); break; case MouseEvent.RELEASE: - mouseReleased(); + mouseReleased(event); break; case MouseEvent.CLICK: - mouseClicked(); + mouseClicked(event); break; case MouseEvent.DRAG: - mouseDragged(); + mouseDragged(event); break; case MouseEvent.MOVE: - mouseMoved(); + mouseMoved(event); break; case MouseEvent.ENTER: - mouseEntered(); + mouseEntered(event); break; case MouseEvent.EXIT: - mouseExited(); + mouseExited(event); break; } @@ -2617,38 +2617,83 @@ public class PApplet extends Activity implements PConstants, Runnable { public void mousePressed() { } + + public void mousePressed(MouseEvent event) { + mousePressed(); + } + + public void mouseReleased() { } + + public void mouseReleased(MouseEvent event) { + mouseReleased(); + } + + + /** + * mouseClicked is currently not fired at all (no direct match on Android). + * http://code.google.com/p/processing/issues/detail?id=215 + */ public void mouseClicked() { } + + public void mouseClicked(MouseEvent event) { + mouseClicked(); + } + + public void mouseDragged() { } + + public void mouseDragged(MouseEvent event) { + mouseDragged(); + } + + public void mouseMoved() { } + + public void mouseMoved(MouseEvent event) { + mouseMoved(); + } + + public void mouseEntered() { } + + public void mouseEntered(MouseEvent event) { + mouseEntered(); + } + + public void mouseExited() { } + public void mouseExited(MouseEvent event) { + mouseExited(); + } + + ////////////////////////////////////////////////////////////// // unfinished API, do not use - protected void pressEvent() { } - - protected void dragEvent() { } - - protected void moveEvent() { } - - protected void releaseEvent() { } - - protected void zoomEvent(float x, float y, float d0, float d1) { } - - protected void tapEvent(float x, float y) { } - - protected void swipeEvent(float x0, float y0, float x1, float y1) { } +// protected void pressEvent() { } +// +// protected void dragEvent() { } +// +// protected void moveEvent() { } +// +// protected void releaseEvent() { } +// +// protected void zoomEvent(float x, float y, float d0, float d1) { } +// +// protected void tapEvent(float x, float y) { } +// +// protected void swipeEvent(float x0, float y0, float x1, float y1) { } ////////////////////////////////////////////////////////////// @@ -2677,18 +2722,18 @@ public class PApplet extends Activity implements PConstants, Runnable { protected void handleKeyEvent(KeyEvent event) { - keyEvent = event; +// keyEvent = event; key = event.getKey(); keyCode = event.getKeyCode(); switch (event.getAction()) { case KeyEvent.PRESS: keyPressed = true; - keyPressed(); + keyPressed(event); break; case KeyEvent.RELEASE: keyPressed = false; - keyReleased(); + keyReleased(event); break; } @@ -2740,81 +2785,37 @@ public class PApplet extends Activity implements PConstants, Runnable { } - /** - * Overriding keyXxxxx(KeyEvent e) functions will cause the 'key', - * 'keyCode', and 'keyEvent' variables to no longer work; - * key events will no longer be queued until the end of draw(); - * and the keyPressed(), keyReleased() and keyTyped() methods - * will no longer be called. - */ -// public void keyPressed(KeyEvent e) { checkKeyEvent(e); } -// public void keyReleased(KeyEvent e) { checkKeyEvent(e); } -// public void keyTyped(KeyEvent e) { checkKeyEvent(e); } - - - /** - * Called each time a single key on the keyboard is pressed. - * Because of how operating systems handle key repeats, holding - * down a key will cause multiple calls to keyPressed(), because - * the OS repeat takes over. - *

- * Examples for key handling: - * (Tested on Windows XP, please notify if different on other - * platforms, I have a feeling Mac OS and Linux may do otherwise) - *

-   * 1. Pressing 'a' on the keyboard:
-   *    keyPressed  with key == 'a' and keyCode == 'A'
-   *    keyTyped    with key == 'a' and keyCode ==  0
-   *    keyReleased with key == 'a' and keyCode == 'A'
-   *
-   * 2. Pressing 'A' on the keyboard:
-   *    keyPressed  with key == 'A' and keyCode == 'A'
-   *    keyTyped    with key == 'A' and keyCode ==  0
-   *    keyReleased with key == 'A' and keyCode == 'A'
-   *
-   * 3. Pressing 'shift', then 'a' on the keyboard (caps lock is off):
-   *    keyPressed  with key == CODED and keyCode == SHIFT
-   *    keyPressed  with key == 'A'   and keyCode == 'A'
-   *    keyTyped    with key == 'A'   and keyCode == 0
-   *    keyReleased with key == 'A'   and keyCode == 'A'
-   *    keyReleased with key == CODED and keyCode == SHIFT
-   *
-   * 4. Holding down the 'a' key.
-   *    The following will happen several times,
-   *    depending on your machine's "key repeat rate" settings:
-   *    keyPressed  with key == 'a' and keyCode == 'A'
-   *    keyTyped    with key == 'a' and keyCode ==  0
-   *    When you finally let go, you'll get:
-   *    keyReleased with key == 'a' and keyCode == 'A'
-   *
-   * 5. Pressing and releasing the 'shift' key
-   *    keyPressed  with key == CODED and keyCode == SHIFT
-   *    keyReleased with key == CODED and keyCode == SHIFT
-   *    (note there is no keyTyped)
-   *
-   * 6. Pressing the tab key in an applet with Java 1.4 will
-   *    normally do nothing, but PApplet dynamically shuts
-   *    this behavior off if Java 1.4 is in use (tested 1.4.2_05 Windows).
-   *    Java 1.1 (Microsoft VM) passes the TAB key through normally.
-   *    Not tested on other platforms or for 1.3.
-   * 
- */ public void keyPressed() { } + public void keyPressed(KeyEvent event) { + keyPressed(); + } + + /** * See keyPressed(). */ public void keyReleased() { } + public void keyReleased(KeyEvent event) { + keyReleased(); + } + + /** - * Only called for "regular" keys like letters, - * see keyPressed() for full documentation. + * Never currently called (does not exist) on Android. + * http://code.google.com/p/processing/issues/detail?id=1489 */ public void keyTyped() { } + public void keyTyped(KeyEvent event ) { + keyTyped(); + } + + ////////////////////////////////////////////////////////////// diff --git a/android/todo.txt b/android/todo.txt index ff3911fae..e338c401c 100644 --- a/android/todo.txt +++ b/android/todo.txt @@ -15,6 +15,7 @@ X check on this, fixed one, all set o gui stuff: http://hg.postspectacular.com/cp5magic/wiki/Home X OpenGL sketches crashes on older Android devices X http://code.google.com/p/processing/issues/detail?id=1455 +X remove mouseEvent and keyEvent variables (deprecated on desktop) earlier X inside AndroidPreprocessor @@ -89,7 +90,6 @@ _ re: android libraries, from shawn van every The most powerful part were the libraries (and the ease with which they could be developed). Location, SMS, Camera/Video, Bluetooth (for Arduino integration) and PClient/PRequest were by far the most used. The ones that came with it, plus the ones from MJSoft were good though I ended up making a couple of very specific ones for my students: http://www.mobvcasting.com/wp/?cat=4 _ process trackball events (they're only deltas) -_ handle repeat key events _ implement link() _ error in 'create avd' with "Emulator already exists" when it needs an upgrade @@ -204,6 +204,8 @@ _ http://code.google.com/p/processing/issues/detail?id=552 _ implement tap detection and set correct click count for mouseClicked() _ mouseClicked is currently not fired at all (no direct match on Android) _ http://code.google.com/p/processing/issues/detail?id=215 +_ keyTyped() does not exist on Android +_ http://code.google.com/p/processing/issues/detail?id=1489 _ implement multiple pointers and multi-touch _ http://code.google.com/p/processing/issues/detail?id=243 diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 07eaac48e..7a97eb370 100644 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -567,6 +567,11 @@ public class PApplet extends Applet */ public boolean mousePressed; + + /** + * @deprecated Use a mouse event handler that passes an event instead. + */ + @Deprecated public MouseEvent mouseEvent; /** @@ -655,9 +660,12 @@ public class PApplet extends Applet */ public boolean keyPressed; + /** * The last KeyEvent object passed into a mouse function. + * @deprecated Use a key event handler that passes an event instead. */ + @Deprecated public KeyEvent keyEvent; /** @@ -2582,26 +2590,26 @@ public class PApplet extends Applet switch (event.getAction()) { case MouseEvent.PRESS: // mousePressed = true; - mousePressed(); + mousePressed(event); break; case MouseEvent.RELEASE: // mousePressed = false; - mouseReleased(); + mouseReleased(event); break; case MouseEvent.CLICK: - mouseClicked(); + mouseClicked(event); break; case MouseEvent.DRAG: - mouseDragged(); + mouseDragged(event); break; case MouseEvent.MOVE: - mouseMoved(); + mouseMoved(event); break; case MouseEvent.ENTER: - mouseEntered(); + mouseEntered(event); break; case MouseEvent.EXIT: - mouseExited(); + mouseExited(event); break; } @@ -2786,6 +2794,11 @@ public class PApplet extends Applet public void mousePressed() { } + public void mousePressed(MouseEvent event) { + mousePressed(); + } + + /** * ( begin auto-generated from mouseReleased.xml ) * @@ -2804,6 +2817,12 @@ public class PApplet extends Applet */ public void mouseReleased() { } + + public void mouseReleased(MouseEvent event) { + mouseReleased(); + } + + /** * ( begin auto-generated from mouseClicked.xml ) * @@ -2827,6 +2846,11 @@ public class PApplet extends Applet public void mouseClicked() { } + public void mouseClicked(MouseEvent event) { + mouseClicked(); + } + + /** * ( begin auto-generated from mouseDragged.xml ) * @@ -2845,6 +2869,11 @@ public class PApplet extends Applet public void mouseDragged() { } + public void mouseDragged(MouseEvent event) { + mouseDragged(); + } + + /** * ( begin auto-generated from mouseMoved.xml ) * @@ -2863,12 +2892,27 @@ public class PApplet extends Applet public void mouseMoved() { } + public void mouseMoved(MouseEvent event) { + mouseMoved(); + } + + public void mouseEntered() { } + public void mouseEntered(MouseEvent event) { + mouseEntered(); + } + + public void mouseExited() { } + public void mouseExited(MouseEvent event) { + mouseExited(); + } + + ////////////////////////////////////////////////////////////// @@ -2948,14 +2992,14 @@ public class PApplet extends Applet switch (event.getAction()) { case KeyEvent.PRESS: keyPressed = true; - keyPressed(); + keyPressed(keyEvent); break; case KeyEvent.RELEASE: keyPressed = false; - keyReleased(); + keyReleased(keyEvent); break; case KeyEvent.TYPE: - keyTyped(); + keyTyped(keyEvent); break; } @@ -3129,6 +3173,11 @@ public class PApplet extends Applet public void keyPressed() { } + public void keyPressed(KeyEvent event) { + keyPressed(); + } + + /** * ( begin auto-generated from keyReleased.xml ) * @@ -3146,6 +3195,11 @@ public class PApplet extends Applet public void keyReleased() { } + public void keyReleased(KeyEvent event) { + keyReleased(); + } + + /** * ( begin auto-generated from keyTyped.xml ) * @@ -3165,6 +3219,12 @@ public class PApplet extends Applet public void keyTyped() { } + public void keyTyped(KeyEvent event) { + keyTyped(); + } + + + ////////////////////////////////////////////////////////////// // i am focused man, and i'm not afraid of death. diff --git a/core/todo.txt b/core/todo.txt index 31e8292ce..403e8e2e1 100644 --- a/core/todo.txt +++ b/core/todo.txt @@ -27,6 +27,12 @@ X add warning message when registering AWT mouse/key events X don't let OpenGL fire those mouse events at all X phrase the warning differently when OpenGL is in use (or only show then?) X halt with OpenGL, otherwise will be ignored +X show warning when registering mouse/key events with OpenGL +X deprecate mouseEvent and keyEvent +X add functions for mousePressed(event) and keyPressed(event) et al +X better to do this instead of bringing back the magic event +X or implementing the magic event on Android +X also problematic with it not being called now decisions on data @@ -71,11 +77,6 @@ X saveTable("filename.tsv") or saveTable("filename.txt", "tsv") X createTable() method in PApplet X removed getUniqueXxxx() and some others, pending names -_ implement mousePressed(Event) etc -_ better to do this instead of bringing back the magic event -_ or implementing the magic event on Android -_ also problematic with it not being called now - _ shader syntax (Andres request) _ might also need a define inside the shader to control what type it is @@ -642,6 +643,8 @@ _ before rewriting all of createInput() LATER (post 2.0) +_ handle repeat key events +_ and/or holding keys down and discerning repeats _ fillMode(NONZERO) and fillMode(ODD) to replace solid(boolean)? _ create PVec2D and PVec3D as separate classes _ gui priorities