Setting Mouse Cursor Doesn't Work
Last post 05-18-2007 3:15 PM by Scooter5791. 5 replies.
Sort Posts:
05-18-2007 10:23 AM
Setting Mouse Cursor Doesn't Work

I have handlers for MouseEnter and MouseLeave events for some TextBlock navigation links.  I am changing the text color and the mouse cursor on mouse rollovers.  The text color is working fine but the mouse cursor does not change.  In the words of Robin Leach as portrayed by Dana Carvey - "I don't know why".

function handleMainNavMouseEnter(sender, eventArgs)

{

sender.setValue(
"Foreground", "#FF0A1E60"); sender.setValue("Cursor", "Hand");

 

}

function handleMainNavMouseLeave(sender, eventArgs)

{

sender.setValue(
"Foreground", "#FFFFFFFF"); sender.setValue("Cursor", "Arrow");

 

}

Scooter5791

Loading...
Joined on 05-15-2007
Posts 12
05-18-2007 1:48 PM
Re: Setting Mouse Cursor Doesn't Work

Ok, I see now.  I don't need to do this in dynamic code (duh).  All I had to do was set Cursor="Hand" in the XAML for the TextBlock and when the mouse is over the object the hand cursor appears as it should.  But it seems like it should have worked in code also.  But it did not.

Scooter5791

Loading...
Joined on 05-15-2007
Posts 12
05-18-2007 2:01 PM
Marked as Answer
Re: Setting Mouse Cursor Doesn't Work

We currently have a bug where setting the cursor property programmatically doesn't work unless you mouse out of the element and then back in.

-mark
Program Manager
Microsoft
This post is provided "as-is"

 

Mark Rideout

Loading...
Joined on 01-03-2006
Redmond, WA
Posts 226
05-18-2007 2:36 PM
Re: Setting Mouse Cursor Doesn't Work

Thanks for the info Mark.  As I play with this now I am seeing that this appears to not be a bug just when doing it programmatically but a general bug.  I have several canvases with numerous text links which are all set to use the hand cursor in the XAML.  At first they all work fine, but very soon after that they all stop working.  I can only move the mouse over them for a very short period of time and then the cursor changes stop working altogether.

Scooter5791

Loading...
Joined on 05-15-2007
Posts 12
05-18-2007 2:46 PM
Marked as Answer
Re: Setting Mouse Cursor Doesn't Work

We also have a bug where moving outside the control in FireFox and then moving back in doesn't update the cursor. Is that what you are seeing? Does the cursor stop changing if you move the mouse around inside the Silverlight control or is it a combination of moving it in and out of the control?

Note we have a bug forum now so if you can provide a small repro of the issue (and some details on your browser) please file it here: http://silverlight.net/forums/28.aspx  

-mark
Program Manager
Microsoft
This post is provided "as-is"

Mark Rideout

Loading...
Joined on 01-03-2006
Redmond, WA
Posts 226
05-18-2007 3:15 PM
Re: Setting Mouse Cursor Doesn't Work

Never mind Mark, it's me Embarrassed.  After I added the Cursor="Hand" in my XAML I forgot to remove my javascript code in the handlers and that dynamic code was causing the problem.  After removing the javascript code it seems to work fine.  I am testing in XP and IE right now, haven't tried Firefox yet but I definitely will.

Scooter5791

Loading...
Joined on 05-15-2007
Posts 12
Page view counter