Mouse cursor API
Posted Wednesday, 12 March, 2008 - 12:09 by teichgraf in
I am asking me right now, if point 7 for version 0.9.2
7. [0%] Mouse pointer grabbing/hiding.
also prevents the changing of the mouse icon, when you move from the border of the window to the center.
At the moment the mouse icon will be a double arrow after it was moved from the border or the window was resized:

[Editor comment: Discussion moved from the Roadmap]




Comments
Mar 12
12:09:59Re: Mouse cursor API
posted by the FiddlerYes, the pointer will be fixed in 0.9.2. As always, if you happen to know the winapi calls that achieve this, you are welcome to submit a patch. :)
Mar 12
12:10:00Re: Mouse cursor API
posted by teichgrafI think there is no WinAPI call needed at all.
I just tried the following:
{
base.OnUpdateFrame(e);
// Set default mouse cursor
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
// ...
}
And it seems to work.
It would be nicer to have events like
EnterWindow,LeaveWindow. And set the above property just inEnterWindowand not everytime inUpdateFrame.It would be even better, do have a user drawn OGL mouse pointer. GameWindow would have has a property
Bitmap Cursor, which will be used as a texture for a quad, representing the mouse cursor. And in eachbase.OnRenderthe mouse pointer is drawn.Maybe I'll give it a try. What do you think?
Mar 12
12:10:18Re: Mouse cursor API
posted by the FiddlerSystem.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
On one hand, this will tie us to Windows.Forms. On the other hand, this is supported everywhere (including the compact framework and Mono X11/OSX), so we might as well reuse existing code. I'll hack it internally for 0.9.1, to fix the ugly cursor, and see how to provide an API for this in 0.9.2.
Regarding OpenTK drawing the cursor, that's a no no :) The less OpenTK uses OpenGL, the better (what happens once GL3 is out? Do we rewrite everything?) The only part in OpenTK that actually calls OpenGL are Fonts, and even these have been moved outside the core library in 0.9.1.
In any case, it's trivial for the user to provide this functionality: just hide the cursor (through the API that will be provided in the future), and draw a quad on the correct position.
Mar 12
12:31:00Re: Mouse cursor API
posted by teichgrafYou are right. I reconsidered my previous idea and I also thought that it is not the best idea. You have to set a projection matrix, Gl.Pop... and so on.
By the way, it is very easy to set a custom cursor using .Net:
System.Windows.Forms.Cursor myCursor = new System.Windows.Forms.Cursor(bitmap.GetHicon());
System.Windows.Forms.Cursor.Current = myCursor;
//...
// Don't forget to dispose later
myCursor.Dispose();
Even alpha channel is supported.
Mar 12
12:33:16Re: Mouse cursor API
posted by the FiddlerThis is quite cool. I'm currently trying to confirm what I said earlier (that the Cursor is available on all platforms). If it is, then this is awesome.