How to programmatically Move MouseCursor to make InvisibleCursor

  1. last year

    William R

    7 Jan 2016 Pre-Release Testers, Xojo Pro

    I'm developing an app to run on RPi, so it's a Linux/Desktop app. I'm using the following in the Activate event of each Window in the app:

    app.MouseCursor=System.Cursors.InvisibleCursor

    ...and it works to 'hide' the MouseCursor, but only when the mouse position is moved slightly. The app is a touch-screen piece of instrumentation, and I'd like to keep the interface clean and get rid of the mouse all together. For whatever reason the "arrow" cursor appears onscreen when the apps finished showing the Window, and the moment you move the mouse it then properly hides, and stays invisible for the remainder of the time, until you change screens (do a Show of a new Window in the app).

    Is there a way for me to call a function to 'move' the Cursor off-screen? My assumption is that if I both move it, and hide it, that this will assure the desired behavior.

    Thanks for your feedback!

    -Bill

    @WilliamReynolds I sure have. In fact I've placed that line of code in the App Open event, the Windows Open event, and the Windows Activate event. I've currently got it in all three places and the behavior is identical. Again it works to hide the cursor - but only if you wiggle the mouse (or in my case, touch any point on the capacitance touch-screen). Which takes me back to asking, is there a way to programmatically move the mouse off-screen?

    That would require declares that do not exist yet. But it seems possible, from this discussion about the same topic in C.
    http://stackoverflow.com/questions/2433447/how-to-set-mouse-cursor-position-in-c-on-linux

  2. Greg O

    7 Jan 2016 Xojo Inc Somewhere near Raleigh, NC

    Have you tried that the the app's open event?

  3. William R

    8 Jan 2016 Pre-Release Testers, Xojo Pro

    I sure have. In fact I've placed that line of code in the App Open event, the Windows Open event, and the Windows Activate event. I've currently got it in all three places and the behavior is identical. Again it works to hide the cursor - but only if you wiggle the mouse (or in my case, touch any point on the capacitance touch-screen). Which takes me back to asking, is there a way to programmatically move the mouse off-screen?

  4. Michel B

    8 Jan 2016 Pre-Release Testers, Xojo Pro Answer

    @WilliamReynolds I sure have. In fact I've placed that line of code in the App Open event, the Windows Open event, and the Windows Activate event. I've currently got it in all three places and the behavior is identical. Again it works to hide the cursor - but only if you wiggle the mouse (or in my case, touch any point on the capacitance touch-screen). Which takes me back to asking, is there a way to programmatically move the mouse off-screen?

    That would require declares that do not exist yet. But it seems possible, from this discussion about the same topic in C.
    http://stackoverflow.com/questions/2433447/how-to-set-mouse-cursor-position-in-c-on-linux

  5. William R

    8 Jan 2016 Pre-Release Testers, Xojo Pro

    Thanks Michel. I was hoping to keep it all in the Xojo framework - but I appreciate your link. If I find a good solution I'll post it here.

  6. Scott S

    8 Jan 2016 Pre-Release Testers Waukesha, WI USA

    I see that you have the mouse hidden in open and activate events. What about hiding it in a timer, after the window opens?

  7. William R

    8 Jan 2016 Pre-Release Testers, Xojo Pro

    I just gave that a try - no good :-( I think I'll tinker with repainting the layout, and other UI updating actions that I can trigger...

  8. Ulrich B

    8 Jan 2016 Pre-Release Testers, Xojo Pro Xojo Deutschland-Evangelist ·...

    Are you sure it has to do with moving the mouse? Sounds to me like the cursor view doesn’t refresh automatically and the move triggers the refresh. Bad thing is: MouseCursor has no view property. Nothing changed then, without declares I see no way. Maybe time for a feedback request to add an invalidate to a mousecursor change? (If it should be the reason)

  9. Michel B

    8 Jan 2016 Pre-Release Testers, Xojo Pro

    Check http://tuxradar.com/content/xdotool-script-your-mouse which allows moving the mouse by shell.

    You may also try to change the mouse cursor in the window, and do a Window.refresh. It is possible that could reinitialize the mouse cursor.

  10. 2 months ago

    John A

    Feb 16 Pre-Release Testers, Xojo Pro Las Vegas, Nevada

    I'm seeing this effect on the Pi as well.
    It doesn't matter where you put the System.Cursors.Hide statement or if you use me.MouseCursor=System.Cursors.InvisibleCursor, the mouse doesn't
    dissapear until you manually move/wiggle it.

    There is a package for raspbian called unclutter that douses the cursor after a second of non-use.
    Once gone, it stays gone.

or Sign Up to reply!