Skip to content

Commit 77f3078

Browse files
committed
added mouseButton and getCount() for compatibility
1 parent f8c1018 commit 77f3078

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

core/src/processing/core/PApplet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ public class PApplet extends Object implements ActivityAPI, PConstants {
178178
*/
179179
public int pmouseX, pmouseY;
180180

181+
public int mouseButton;
181182

182183
public boolean mousePressed;
183184

@@ -2089,7 +2090,7 @@ protected void handleMouseEvent(MouseEvent event) {
20892090
// }
20902091

20912092
// Get the (already processed) button code
2092-
// mouseButton = event.getButton();
2093+
mouseButton = event.getButton();
20932094

20942095
// Added in 0215 (2.0b7) so that pmouseX/Y behave more like one would
20952096
// expect from the desktop. This makes the ContinousLines example behave.

core/src/processing/event/MouseEvent.java

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class MouseEvent extends Event {
3636

3737
protected int x, y;
3838
protected int button;
39-
protected int clickCount;
39+
protected int count;
4040

4141

4242
// public MouseEvent(int x, int y) {
@@ -48,13 +48,13 @@ public class MouseEvent extends Event {
4848

4949
public MouseEvent(Object nativeObject,
5050
long millis, int action, int modifiers,
51-
int x, int y, int button, int clickCount) {
51+
int x, int y, int button, int count) {
5252
super(nativeObject, millis, action, modifiers);
5353
this.flavor = MOUSE;
5454
this.x = x;
5555
this.y = y;
5656
this.button = button;
57-
this.clickCount = clickCount;
57+
this.count = count;
5858
}
5959

6060

@@ -79,8 +79,23 @@ public int getButton() {
7979
// }
8080

8181

82+
@Deprecated
8283
public int getClickCount() {
83-
return clickCount;
84+
return count;
85+
}
86+
87+
88+
/**
89+
* Number of clicks for mouse button events, or the number of steps (positive
90+
* or negative depending on direction) for a mouse wheel event.
91+
* Wheel events follow Java (see <a href="http://docs.oracle.com/javase/6/docs/api/java/awt/event/MouseWheelEvent.html#getWheelRotation()">here</a>), so
92+
* getAmount() will return "negative values if the mouse wheel was rotated
93+
* up or away from the user" and positive values in the other direction.
94+
* On Mac OS X, this will be reversed when "natural" scrolling is enabled
95+
* in System Preferences &rarr Mouse.
96+
*/
97+
public int getCount() {
98+
return count;
8499
}
85100

86101

0 commit comments

Comments
 (0)