the Fiddler's picture

[NativeWindow] Add ability to hide/show/modify the mouse cursor

Project:The Open Toolkit library
Version:1.1.0-stable
Component:Code
Category:feature request
Priority:critical
Assigned:the Fiddler
Status:closed
Description

Currently, the only way to do this is to set System.Windows.Forms.Cursor.Current to an empty cursor (Cursor.Hide() is not supported on Mono).

OpenTK applications should not need to rely on WinForms for this functionality.


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

Priority:normal» critical

Bumping priority.

jdomnitz's picture

#2

If I throw up code for each GLNative implementation (for each platform) will that work? Or do you want a full patch including changing the interfaces leading up to it?

the Fiddler's picture

#3

Status:open» in progress

I just implemented this on X11 but I'm missing windows/mac implementations. I believe I can cook something up for windows without too much trouble but I would love some help with the mac implementation (OpenTK is currently using Carbon).

The API is pretty simple:

gameWindow.CursorVisible = true/false;

A patch against trunk is best but even example code is fine (the changes are pretty simple and self-contained here).

Edit: initial implementation for X11 is committed to trunk, it's still buggy though. You can test the code using Examples->OpenTK->GameWindow States.

jdomnitz's picture

#4

windows is just this:
http://msdn.microsoft.com/en-us/library/ms648396(VS.85).aspx

i'll see if I can work something out for OSX but thats the one platform I don't know a lot about

the Fiddler's picture

#5

Thanks, committed the windows implementation.

jdomnitz's picture

#6

Cool...and then for OSX:

Its CGDisplayHideCursor and CGDisplayShowCursor from the quartz API:

see here:
http://developer.apple.com/library/mac/#DOCUMENTATION/GraphicsImaging/Re...

the Fiddler's picture

#7

Thanks.

The final piece of the puzzle is whether we should confine the pointer inside the window whenever it becomes invisible. We can either provide a different API for this or we do this automatically. Is there any reason why one might like to have an invisible pointer that is *not* confined to the window?

c2woody's picture

#8

Maybe make this an optional parameter to the Hide function. Not sure what the parameter-less function should default to.

jdomnitz's picture

#9

Yea I prefer the ShowCursor and HideCursor approach (how .net does it) compared to the single Property.... but two ways this can be done:
Either stub out APIs for all the platforms just to limit the mouse to a set bounds...or implement the rawhardware backend and not worry about it (if we have a raw hardware handle we really don't care where the cursor is just that its invisible).

the Fiddler's picture

#10

These methods don't hide the cursor globally - once the cursor leaves the window, it becomes visible again. Raw input doesn't affect this.

I'll run a few tests to find out what the best approach is.