getting mouse cursor position, keeping it hidden?

  • My app uses a fullscreen OpenGL context, and hides the mouse while
    running, but needs mouse events.
    So when entering fullscreen I hide and disassociate the cursor. And
    show and associate it when exiting fullscreen.

    No problems, unless the cursor happened to be over the menubar when I
    entered fullscreen. If so, the cursor becomes visible when clicking
    (why?!)

    So, I figure I can just warp the cursor somewhere safe, like the center
    of the screen, to avoid that. But here's my problem: how do I warp it
    back to the original location? There doesn't appear to be a
    CGGetMousePosition() that returns a point in screen coordinates. So,
    dumb question maybe, but how do you warp to currentposition.x,
    currentposition.y+25?

    _______________________________________________
    MacOSX-dev mailing list
    <MacOSX-dev...>
    http://www.omnigroup.com/mailman/listinfo/macosx-dev
  • On Aug 27, 2004, at 2:28 AM, Alex Eddy wrote:
    > My app uses a fullscreen OpenGL context, and hides the mouse while
    > running, but needs mouse events.
    > So when entering fullscreen I hide and disassociate the cursor. And
    > show and associate it when exiting fullscreen.
    >
    > No problems, unless the cursor happened to be over the menubar when I
    > entered fullscreen. If so, the cursor becomes visible when clicking
    > (why?!)
    >
    > So, I figure I can just warp the cursor somewhere safe, like the
    > center of the screen, to avoid that. But here's my problem: how do I
    > warp it back to the original location? There doesn't appear to be a
    > CGGetMousePosition() that returns a point in screen coordinates. So,
    > dumb question maybe, but how do you warp to currentposition.x,
    > currentposition.y+25?

    Replying to myself (for the archive):

    Of course, [NSEvent mouselocation] will give the current location, but
    this has to be flipped vertically in the current NSScreen coordinates
    to restore via CGWarpMouseCursorPosition.

    However, I found that [NSMenu setMenuBarVisible:NO] prevents the menu
    bar and Dock from interfering with the mouse visibility, so the better
    solution seem to be to always hide the menu bar when capturing the
    display, even though it doesn't seem like it should be necessary.
previous month august 2004 next month
MTWTFSS
            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
Go to today