[vtkusers] VTK tutorial, step 5 (Cone5), OSX-Cocoa: fails to capture keyboard events

Darren Weber darren.weber.lists at gmail.com
Fri Mar 20 17:01:13 EDT 2009


I have this issue with VTK that is compiled for Cocoa.  It appears this fix
is only for CARBON, right?

Best, Darren


On Thu, Mar 19, 2009 at 4:09 PM, Michael Jackson <
mike.jackson at bluequartz.net> wrote:

> These are from my own notes about the render window not getting the key
> events.. or maybe it was the mouse events:
>
>
> I recently moved up to Leopard and this is now hitting me also so I went
> looking around and here is the solution that I came up with and it would
> seem to work all the way back to Panther (10.3.x). This is probably ONLY
> necessary if you build VTK with Carbon instead of Cocoa. You would build
> against Carbon in the following Situations:
>  * You will be using Qt versions 4.0 through at least Qt 4.4
>  * You are using another toolkit that requires Carbon?
>  * You are building ParaView 3.2 or probably ParaView 3.4 (which uses Qt
> 4.3/Qt 4.4)
>
> I added the following code to my "main" method:
>
> In your “main” method have the following:
>
> #ifdef __APPLE__ && defined (VTK_USE_CARBON)
> #include <Processes.h>
> void Apple_Carbon_Focus_Fix()
> {
>  ProcessSerialNumber psn = { 0, kCurrentProcess };
>  OSErr err = GetCurrentProcess (&psn);
>  OSStatus status =  TransformProcessType ( &psn,
> kProcessTransformToForegroundApplication);
> }
> #else
> void Apple_Carbon_Focus_Fix()
> {
> }
> #endif
>
> // ----------------------------------------------
> int main(int argc, char* argv[])
> {
>
>  Apple_Carbon_Focus_Fix();
>
>  return 0;
> }
>
>
> Then in your CMakeLists.txt file have the following (VTK is used as the
> example)
> # This must be AFTER the VTK package has been found....
> IF (APPLE AND VTK_USE_CARBON)
>       # We must include this header directory in order to use some carbon
> specific calls
>       INCLUDE_DIRECTORIES("/Developer/Headers/FlatCarbon")
> END IF (APPLE AND VTK_USE_CARBON)
>
>
> _________________________________________________________
> Mike Jackson                  mike.jackson at bluequartz.net
> BlueQuartz Software                    www.bluequartz.net
> Principal Software Engineer                  Dayton, Ohio
>
>
>
>
> On Mar 19, 2009, at 7:03 PM, Sean McBride wrote:
>
>  On 3/19/09 3:58 PM, Darren Weber said:
>>
>>  I'm not yet versed in Cocoa to make the change required.  I can follow
>>> specific instructions...  I wonder if the keyboard event capture should
>>> apply at the level of the window or at the level of the interactor?
>>>
>>
>> The snippit you had was good (wrong header though), so just paste it
>> into the vtkCocoaRenderWindowInteractor constructor:
>>
>> #include <ApplicationServices/ApplicationServices.h>
>>
>> ProcessSerialNumber psn = { 0, kCurrentProcess };
>> OSStatus error = TransformProcessType( &psn,
>> kProcessTransformToForegroundApplication );
>> assert (error == noErr);
>>
>> --
>> ____________________________________________________________
>> Sean McBride, B. Eng                 sean at rogue-research.com
>> Rogue Research                        www.rogue-research.com
>> Mac Software Developer              Montréal, Québec, Canada
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.vtk.org/mailman/listinfo/vtkusers
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090320/97536e51/attachment.htm>


More information about the vtkusers mailing list