[vtkusers] [Probably repetitive] Tcl VTK under OSX 10.5.4 mouse/keyboard events?

Mike Jackson mike.jackson at bluequartz.net
Wed Sep 3 12:13:52 EDT 2008


On Sep 2, 2008, at 8:41 AM, William Ray wrote:

> I can't be the first person to have this problem, so this has
> undoubtedly been discussed before - I just can't seem to find any
> useful reference to it.
>
>
> VTK fresh from CVS, compiling on an essentially virgin 10.5.4 OSX  
> system.
>
> vtk Medical1.tcl
>
> Window won't focus - this is well known and expected.  The old
> add a resource trick doesn't work.  Everyone suggests stuffing
> it into an .app wrapper.


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:

//  
-----------------------------------------------------------------------------
//  Needed to move background tasks to foreground tasks on OS X
//  
-----------------------------------------------------------------------------
#ifdef __APPLE__ && defined (VTK_USE_CARBON)
#include <Processes.h>
#define APPLE_FOCUS_FIX \
   ProcessSerialNumber psn = { 0, kCurrentProcess };\
   OSErr err = GetCurrentProcess (&psn);\
   OSStatus status =  TransformProcessType ( &psn,  
kProcessTransformToForegroundApplication);
#endif


int main(int argc, char* argv[])
{
#ifdef __APPLE__ && defined (VTK_USE_CARBON)
   APPLE_FOCUS_FIX;
#endif


}

And then in the CMakeLists.txt file I also have the following:
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")
ENDIF (APPLE AND VTK_USE_CARBON)


I used to use the "Rez" solution but it looks like this did not work  
under Leopard. I have tested this with a simple vtk test application  
that does some simple rendering and it seems to work. I get the Dock  
icon and I can use the mouse to bring the Render window to the  
foreground.

I just wanted to get this on the list for archival and in case anyone  
else needs to know. I guess I should post it to the Wiki also..

Is this what everyone else is using on OS X or did I just completely  
do the "wrong" thing?

  _________________________________________________
| Mike Jackson - Principal Software Engineer      |
| BlueQuartz Software                             |
| mike.jackson at bluequartz.net                     |
| www.bluequartz.net                              |
---------------------------------------------------









More information about the vtkusers mailing list