# Mouse cursor resets on repainting

**URL:** <https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584>\
**Category:** General JUCE discussion\
**Created:** [October 10, 2017, 1:12pm UTC](https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584 "2017-10-10T13:12:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ehsanen1](https://avatars.discourse-cdn.com/v4/letter/e/c4cdca/32.png) [@ehsanen1](https://forum.juce.com/u/ehsanen1)\
**Post date:** [October 10, 2017, 1:12pm UTC](https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584/1 "2017-10-10T13:12:44Z")

</div>

Hi,  
I am writing a VST PlugIn. I need to change the mouse cursor based on the relative mouse position inside a component.  
I have a function like this:

```
void checkAndSetMouseCursor(int x, int y)
{
	if (EXP1)
		currentMouseCursor = MouseCursor::LeftRightResizeCursor;
	else if (EXP2)
		currentMouseCursor = MouseCursor::UpDownResizeCursor;
	else if (EXP3)
		currentMouseCursor = MouseCursor::NormalCursor;

	updateMouseCursor();
}

```

which I call whenever I detect mouse cursor needs an update. I have also overriden

```
MouseCursor getMouseCursor() 
{
	return currentMouseCursor;
}

```

which returns the `currentMouseCursor` and is supposed to set the correct cursor. I also call `updateMouseCursor()` in multiple locations. Like in pain() function of my component.  
The problem is: when repainting and when mouse cursor is not normal arrow, for a very short moment the mouse cursor will be set back to arrow shape and then sets to whatever it was before. So what the user experiences is that the mouse cursor is flickering all the time.  
Is it really my guess right? Does Juce reset the mouse cursor on repaints?

I have also added an MouseInactivityDetector to my my class and I am calling `updateMouseCursor()`in `mouseBecameInactive()` function, but that doesn’t help.  
Please advice!

BTW I am developing on Windows 10, and using Nuendo 7 as DAW.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 10, 2017, 1:16pm UTC](https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584/2 "2017-10-10T13:16:44Z")

</div>

No, it doesn’t reset the cursor, but you really shouldn’t be calling updateCursor inside a paint call, I don’t know what that would do.

Why not scrap all the calls to udpateMouseCursor and get rid of getMouseCursor, and just use setMouseCursor in response to e.g. a mouse move event or whatever’s appropriate?

---

<div class="post-metadata">

**Author:** ![ehsanen1](https://avatars.discourse-cdn.com/v4/letter/e/c4cdca/32.png) [@ehsanen1](https://forum.juce.com/u/ehsanen1)\
**Post date:** [October 10, 2017, 2:31pm UTC](https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584/3 "2017-10-10T14:31:48Z")

</div>

Thanks for the quick reply.  
I’ve already tried setMouseCursor and got mouse flickering with that as well.  
With further investigation, I think this is something Nuendo specific. As flickering only happens if an audio is running in Nuendo, and when I stop the audio flickering stops, too.  
I’m trying to find some other plugins from other manufacturers to support my assumption.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [October 10, 2017, 2:35pm UTC](https://forum.juce.com/t/mouse-cursor-resets-on-repainting/24584/4 "2017-10-10T14:35:29Z")

</div>

Ah yes, could easily be that the host is forcing the cursor to change.
