processing icon indicating copy to clipboard operation
processing copied to clipboard

Cursor() with P2D doesn't update cursor icon

Open Bjoe1839 opened this issue 6 years ago • 1 comments

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;
    }
  }
}

Bjoe1839 avatar Apr 16 '20 16:04 Bjoe1839

This issue has been automatically closed and locked.

Processing 3.x is no longer actively developed. Since January 2020, development moved to the Processing 4 repository.

If this issue is still relevant to Processing 4, we'd love to hear from you. Please open a new issue at: https://github.com/processing/processing4/issues/new/choose

Thank you for helping improve Processing.

github-actions[bot] avatar Jul 15 '26 15:07 github-actions[bot]