luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NativeWindow does not fire mouse events if the mouse leaves the window

matyasforian opened this issue · comments

Its currently very hard to implement NativeWindow mouse events because of this issue.
Some use cases:
I store it in a variable whether the left mouse button is in a pressed state. I hold down the left button in the app's window, then I move the mouse outside of the window and release it. Since this action does not fire an event when the mouse comes back to the window I still think its pressed resulting in a messed up inner state for my program.

Suggestions:

  • Implement a MouseLeave/MouseEnter event that fires when the mouse leaves/enters the window area. The event should contain which button(s) are pressed.
  • Have the MouseUp fire, if the mouse was pressed inside the window and was released outside.

Not sure if it is appropriate to emulate mouse events because uncaught: they are uncaught because they are not happening on the underlying window. This makes sense.

MouseUp emulation would be implemented it only in the case NativeWindow behaves differently on different platforms (i.e. X11), but I don't think so.

The coherency between MouseDown and MouseUp events (and their arguments) can be easily resolved at the application level (by caching the last mouse state or changing the state logic).

As I see you have pushed a commit, that adds events for the mouse leaving or entering the window area. I think this will solve my use case, thanks