Changing the cursor over a canvas within a container control

Hello Everyone,

I’m experiencing an issue with changing the cursor over a canvas within a container control. Precisely, I have a container control that contains a canvas.
I want to change the cursor when over the container and over the canvas.
When the cursor hovers over the canvas, there’s a glitch where it alternates between the custom cursor I set and the standard cursor. However, when the cursor is over other parts of the container (outside the canvas), the cursor changes as expected.

I’ve attached a sample project that demonstrates the problem. If anyone has any ideas on why this might be happening, I’d appreciate your help!

P.S. I’ve tried moving the MouseMove event handling to the canvas itself, but the issue persists.

Thanks in advance!
cursorTestProject

Are you on MS Windows?

On macOS 14.6.x it works as you expected. No glitch.

Yes Im on MS Windows
Thank you!

Then you should use MouseEnter and MouseExit Event at the Container control.

Sub MouseEnter() Handles MouseEnter
  MouseCursor = System.Cursors.FingerPointer
End Sub
Sub MouseExit() Handles MouseExit
  MouseCursor = System.Cursors.StandardPointer
End Sub

Hope this helps.

2 Likes

You may also need to put the same code in the MouseEnter event of the canvas. It’s certainly possible that the canvas itself is reverting the pointer.

Thank you, it works! :blush:
This is working fine but its giving me a static cursor over the whole container.
what if i need to change the cursor over a specific area over the canvas which is part of the container.

Do you have any suggestions on how to achieve this? :thinking:

Thank you for the suggestion! :blush:
I put the code only the MouseEnter event of the container and it works

1 Like

We found that setting the Cursor of the parent Container to nil and then updating the Canvas cursor resolved the problem, here is an updated version of the project :smile:

cursorTest_Updated