@@ -29,12 +29,20 @@ public class Event {
2929 protected long millis ;
3030 protected int action ;
3131
32- static public final int SHIFT_MASK = 1 << 6 ;
33- static public final int CTRL_MASK = 1 << 7 ;
34- static public final int META_MASK = 1 << 8 ;
35- static public final int ALT_MASK = 1 << 9 ;
32+ // These correspond to the java.awt.Event modifiers (not to be confused with
33+ // the newer getModifiersEx), though they're not guaranteed to in the future.
34+ static public final int SHIFT = 1 << 0 ;
35+ static public final int CTRL = 1 << 1 ;
36+ static public final int META = 1 << 2 ;
37+ static public final int ALT = 1 << 3 ;
3638 protected int modifiers ;
3739
40+ // Types of events. As with all constants in Processing, brevity's preferred.
41+ static public final int KEY = 1 ;
42+ static public final int MOUSE = 2 ;
43+ static public final int TOUCH = 3 ;
44+ protected int flavor ;
45+
3846
3947 public Event (Object nativeObject , long millis , int action , int modifiers ) {
4048 this .nativeObject = nativeObject ;
@@ -44,6 +52,18 @@ public Event(Object nativeObject, long millis, int action, int modifiers) {
4452 }
4553
4654
55+ public int getFlavor () {
56+ return flavor ;
57+ }
58+
59+
60+ /**
61+ * Get the platform-native event object. This might be the java.awt event
62+ * on the desktop, though if you're using OpenGL on the desktop it'll be a
63+ * NEWT event that JOGL uses. Android events are something else altogether.
64+ * Bottom line, use this only if you know what you're doing, and don't make
65+ * assumptions about the class type.
66+ */
4767 public Object getNative () {
4868 return nativeObject ;
4969 }
@@ -85,21 +105,21 @@ public int getModifiers() {
85105
86106
87107 public boolean isShiftDown () {
88- return (modifiers & SHIFT_MASK ) != 0 ;
108+ return (modifiers & SHIFT ) != 0 ;
89109 }
90110
91111
92112 public boolean isControlDown () {
93- return (modifiers & CTRL_MASK ) != 0 ;
113+ return (modifiers & CTRL ) != 0 ;
94114 }
95115
96116
97117 public boolean isMetaDown () {
98- return (modifiers & META_MASK ) != 0 ;
118+ return (modifiers & META ) != 0 ;
99119 }
100120
101121
102122 public boolean isAltDown () {
103- return (modifiers & ALT_MASK ) != 0 ;
123+ return (modifiers & ALT ) != 0 ;
104124 }
105125}
0 commit comments