Mouse cursor resets on repainting


#1

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.


#2

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?


#3

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.


#4

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