vtkCocoaGLView reports incorrect mouse position
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
vtkCocoaGLView reports an incorrect mouse position on MacOS X. To demonstrate, create a Cocoa VTK window and press the mouse button along the left side of the window. The view should rotate to the left. Now, move the window to the right side of the screen. Click the mouse in approximately the same position. The view spins widely to the RIGHT. The is incorrect, as the mouse position should be registered relative to the window, not relative to the screen.
When the class obtains the NSPoint representing the mouse position, it calls -[NSEvent locationInWindow]. Through testing, I verified that this function was returning the screen position for the event, ignoring the request to return the location relative to the window. I eventually tracked this behavior down to the NSPeriodic timer events that are fired. I filed an item with Apple (radar #3168753) in December 2003. The response was, "The fix was just adding clarification to the documentation because the problem is in the test case's use of -locationInWindow. The unexpected coordinates are getting returned when called for NSPeriodic events. the problem here is that you are calling -[NSEvent locationInWindow] for an event for which that method returns undefined values. You could instead call -[NSWindow mouseLocationOutsideOfEventStream] to get the location of the mouse in window relative coordinates."
Another approach may be required to properly handle the timer mechanism. There are workarounds for manually converting the event location into the vtkCocoaGLView's NSRect on the screen, but it would be ideal to determine the proper event mechanism that would avoid such workarounds.