-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Directed from Processing Foundation topic:
https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537
I am using processings P2D renderer and want to change the cursor icon when it has a specific location. This works as expected without the renderer, but with P2D the cursor changes to my computers default cursor after the program has been running for less than a minute and doesn’t change icon when it should. Here’s an example:
void setup() {
size(400, 400, P2D);
}
void draw() {
if (mouseX < width/2) cursor(ARROW);
else cursor(HAND);
}
According to Processings cursor() reference, P2D uses a different set of cursors, but after less than a minute of the example above, the cursor changes to my default cursor again.
From Processing Foundation it was suggested that I only call cursor() at transitions:
if (pmouseX < width/2 && mouseX >= width/2) cursor(HAND);
else if (pmouseX >= width/2 && mouseX < width/2) cursor(ARROW);
This does work as expected, but I still think it is a bug worth looking into.
I have tested this on three different computers. Two of them were not mine and were both gaming computers.
My environment:
Processing 3.5.3
Windows 10 Home
Ver. 10.0.18362 Build 18362
As the troubleshooting page said, I did try to update my graphics drivers, but they were all on the latest version.
EDIT:
I found a very easy and obvious solution by using a boolean:
boolean cursorHand;
void draw() {
if (mouseX > width/2) {
if (!cursorHand) {
cursor(HAND);
cursorHand = true;
}
} else {
if (cursorHand) {
cursor(ARROW);
cursorHand = false;
}
}
}