luca-piccioni / OpenGL.Net

Modern OpenGL bindings for C#.
MIT License
568 stars 108 forks source link

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

Closed matyasforian closed 6 years ago

matyasforian commented 6 years ago

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:

luca-piccioni commented 6 years ago

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).

matyasforian commented 6 years ago

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