# Cursor icon with Processing P2D renderer doesn't update as expected

**URL:** <https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537>\
**Category:** Coding Questions\
**Created:** [April 8, 2020, 11:58am UTC](https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537 "2020-04-08T11:58:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bjoe](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@Bjoe](https://discourse.processing.org/u/Bjoe)\
**Post date:** [April 8, 2020, 11:58am UTC](https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537/1 "2020-04-08T11:58:31Z")

</div>

Hi!  
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:

```auto
void setup() {
  size(400, 400, P2D);
}

void draw() {
  if (mouseX < width/2) cursor(ARROW);
  else cursor(HAND);
}

```

According to [Processings cursor() reference](https://processing.org/reference/cursor_.html), 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.

I’ve tried moving the code in draw() to mouseMoved() but the same result occurs.  
I’ve also tried to replace the cursors with images of cursors with cursor(my\_cursor\_img), but the same thing happens.

Right now the only solution I see is setting the cursor to noCursor() in setup and calling image(my\_cursor\_img, mouseX, mouseY) every frame, but that doesn’t seem like the optimal solution.

Does anyone have any ideas how to fix this?

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 16, 2020, 3:08pm UTC](https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537/2 "2020-04-16T15:08:30Z")

</div>

> [@Bjoe](#):
>
> after less than a minute of the example above, the cursor changes to my default cursor again.

@Bjoe – were you able to resolve this issue? It sounds like it might be a bug worth reporting – along with specific details about your operating system / version:

- [Issues · processing/processing · GitHub](https://github.com/processing/processing/issues)

If I was to guess about workarounds, my first guess would be something like this:

```auto
if (pmouseX < width/2 && mouseX >= width/2) cursor(HAND);
else if (pmouseX >= width/2 && mouseX < width/2) cursor(ARROW);

```

This means that cursor() won’t be called every frame – only on (rare) transition frames. See if that makes the problem better or worse.

---

<div class="post-metadata">

**Author:** ![Bjoe](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@Bjoe](https://discourse.processing.org/u/Bjoe)\
**Post date:** [April 16, 2020, 4:14pm UTC](https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537/3 "2020-04-16T16:14:54Z")

</div>

Your solution works!  
I never thought of only calling the function at transitions, especially since the example at the reference page calls it every frame.

I did however create an issue:

> <https://github.com/processing/processing/issues/6023>
>
> 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...

---

<div class="post-metadata">

**Author:** ![Bjoe](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@Bjoe](https://discourse.processing.org/u/Bjoe)\
**Post date:** [April 16, 2020, 8:53pm UTC](https://discourse.processing.org/t/cursor-icon-with-processing-p2d-renderer-doesnt-update-as-expected/19537/4 "2020-04-16T20:53:54Z")

</div>

I found a much easier (and obvious) solution:

```auto
boolean cursorHand;

void draw() {
  if (mouseX > width/2) {
    if (!cursorHand) {
      cursor(HAND);
      cursorHand = true;
    }
  } else {
    if (cursorHand) {
      cursor(ARROW);
      cursorHand = false;
    }
  }
}

```

This also results in that the function is called only when a change in the cursor icon should happen because of the boolean.
