none
force cursor update RRS feed

  • Question

  • I am changing the cursor in my WPF app in response to various things.  It mostly works correctly.  However, if something like a key command triggers a cursor change the cursor does not update until the mouse moves. 

    Is there a way to force an update of the cursor?  Or tell someone its invalidated or something?  I saw a blog post talking about an UpdateCursor method, but I couldn't find it in any of the documentation.

    Thanks!
    ~Mayra
    Friday, June 20, 2008 6:14 PM

All replies

  • I spoke too soon, I did find the UpdateCursor function, which is a static function on Mouse (I was looking for it in cursors, or on the elements that I set the cursor).  However, it only works sometimes. 

    Specifically, when holding down a key I set the cursor to something, let go and I set it back.  I added a Mouse.UpdateCursor() call to both cursor changes. 

    public void OnKeyDown() 
       this.Cursor = Cursors.Cross; 
       Mouse.UpdateCursor(); 
     
    public void OnKeyUp() 
       this.Cursor = Cursors.Arrow; 
       Mouse.UpdateCursor(); 

    The keydown has the same behavior as before, the cursor does not update until I move the mouse, or a few a seconds have passed.

    The keyup now works properly.  Any ideas?
    Friday, June 20, 2008 6:40 PM
  • -> The keydown has the same behavior as before, the cursor does not update until I move the mouse, or a few a seconds have passed.

    I cannot reproduce this problem, could you please provide a small, complete and ready-to-run example to demonstrate the issue you are encountering?

     

    Thanks

    Wednesday, June 25, 2008 4:51 AM
  • You can force the cursor update moving the mouse :)
    Like this:

    POINT pt; 
    GetCursorPos(&pt);  
    SetCursorPos(pt.x,pt.y); 
    Thursday, September 18, 2008 12:31 PM