-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Description
When setting the cursor shape using cursor(???) where ??? is one of the cursor types listed in PConstants it generates a fake MouseEvent.ENTER event which can be detected if you register the mouseEvent method.
I have tested this using both JAVA2D and P2D/P3D (OpenGL) renderers and this unwanted event only occurred when using OpenGL.
The code below demonstrates the bug. Un-comment any or all the cursor(CROSS) statements, run the sketch and keep the mouse over the frame and you will see the generated events in the console window even if the mouse is stationary.
Relay relay;
public void settings() {
size(300, 200, P2D);
}
public void setup() {
relay = new Relay(this);
}
public void draw() {
background(255, 200, 200);
cursor(HAND);
}
public class Relay {
PApplet pa;
public Relay(PApplet app) {
pa = app;
pa.registerMethod("pre", this);
pa.registerMethod("post", this);
pa.registerMethod("draw", this);
pa.registerMethod("mouseEvent", this);
pa.registerMethod("keyEvent", this);
}
public void pre() {
// cursor(CROSS);
}
public void draw() {
// cursor(CROSS);
}
public void post() {
// cursor(CROSS);
}
public void mouseEvent(MouseEvent event) {
System.out.println(event.toString() + " " + millis());
// cursor(CROSS);
}
public void keyEvent(KeyEvent event) {
System.out.println(event.toString() + " " + millis());
// cursor(CROSS);
}
}
My Environment
macOS 10.13.6
Processing 3.4
I believe that this also occurred in some earlier versions of Processing as well, but have updated Processing while in the process of finding the cause of this issue.