[vtk-developers] Cocoa render window and mouse move events

David Thompson dcthomp at sandia.gov
Wed Aug 25 12:26:26 EDT 2010


Hi Marcus,

You might try changing

   ADD_EXECUTABLE(${KIT}CxxTests ${Tests} )

to

   ADD_EXECUTABLE(${KIT}CxxTests MACOSX_BUNDLE ${Tests} )

in Views/Testing/Cxx/CMakeLists.txt and rebuild. You'll get a ".app"  
executable and when you run

   ./bin/ViewsCxxTests.app/Contents/MacOS/ViewsCxxTests  
TestGraphLayoutView -I

instead of

   ./bin/ViewsCxxTests TestGraphLayoutView -I

you'll see different behavior. (I still had to click the mouse button  
once before hover started working, but after the first click hover  
boxes did start appearing.)

Without being marked as a bundle, Cocoa applications don't get full  
access to keyboard and mouse events from the window manager. This was  
discussed on the list a while back but the platform-dependent naming  
of the test executables made folks wary of adding MACOSX_BUNDLE to the  
test executables, especially since -- as you pointed out -- none of  
the tests listen for actual mouse events.

	David

On Aug 25, 2010, at 8:49 , Marcus D. Hanwell wrote:

> Hi David,
>
> On Wed, Aug 25, 2010 at 11:40 AM, David Thompson  
> <dcthomp at sandia.gov> wrote:
> Hi Marcus,
>
> I think what you're looking for is NSTrackingArea:
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/EventOverview/TrackingAreaObjects/TrackingAreaObjects.html#/ 
> /apple_ref/doc/uid/10000060i-CH8-SW1
>
> Note that it was introduced in MacOS X 10.5, but in the  
> "Compatability Issues" section of the link above is a description of  
> older methods used to track mouse motion. You can also use  
> setAcceptsMouseMovedEvents: method of NSWindow but see
>
> http://developer.apple.com/mac/library/documentation/cocoa/conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html
>
> for the dire warning about flooding the event dispatch mechanism.
>
> Line 579 in Rendering/vtkCocoaRenderWindow.mm seems to be setting  
> that, but for some reason I still don't seem to be getting the mouse  
> move. This is me moving the mouse around very slowly too, and not  
> being very familiar with Cocoa or Objective C++.
>
> Thanks for the pointers, I thought that like was attempting to say  
> the Window would take all mouse moved events. My testing has been on  
> Max OS X Snow Leopard. I will read around a little more.
>
> Thanks,
>
> Marcus
>
> On Aug 25, 2010, at 8:21 , Marcus D. Hanwell wrote:
>
> Hi,
>
> I have been looking into a bug found during some of the work we have  
> been doing in the charts, but the bug also presents itself in the  
> graph layout view,
>
> ./bin/ViewsCxxTests TestGraphLayoutView -I
>
> The vertices should have hover text that shows up when the mouse  
> moves over the vertices. On Linux and Windows the text shows up,  
> whereas on Mac OS X with the Cocoa render window it does now. The  
> same is true of the charts, which have tooltips when the mouse moves  
> over a data point. This works on Linux and Windows, but for Cocoa it  
> does not.
>
> If you use the same charts in a Qt widget, e.g. a QVTKWidget in  
> ParaView, the mouse move events are propagated. It seems when the  
> mouse button is pressed down the mouse move events are propagated,  
> but not if there is no mouse button pressed down. I was hoping that  
> some of the Mac experts on the list might have some ideas as to what  
> might be missing, it would seem that the Qt windows are able to  
> receive these mouse move events, and so our Cocoa render window or  
> interaction translation code could be patched.
>
> Another interesting question, is there any way we can test this? All  
> of the mouse interaction tests inject the events into VTK, and do  
> not actually move the mouse. Is there a cross platform tool we could  
> use to test some of the interaction code, and would it be worth  
> adding to VTK?
>





More information about the vtk-developers mailing list