[vtkusers] VTK tutorial, step 5 (Cone5),	OSX-Cocoa: fails to 	capture keyboard events
    Darren Weber 
    darren.weber.lists at gmail.com
       
    Thu Mar 19 19:19:04 EDT 2009
    
    
  
I've tried this change to vtkCocoaRenderWindow.mm and it seems to be working
when I build Cone6 without the MACOSX_BUNDLE option for cmake.
#include <vtksys/ios/sstream>
#include <CoreServices/CoreServices.h>
.
.
.
//----------------------------------------------------------------------------
void vtkCocoaRenderWindow::MakeCurrent()
{
  if (this->GetContextId())
    {
    [(NSOpenGLContext*)this->GetContextId() makeCurrentContext];
    }
  // ****  BEGIN EDIT
  // Adding process control so the window gets keyboard events.
  ProcessSerialNumber psn = { 0, kCurrentProcess };
  TransformProcessType( &psn, kProcessTransformToForegroundApplication );
  // **** END EDIT
}
I wonder if the 'psn' variable should be put into an init method instead?
If so, I guess there should be a method to get it too.
Best, Darren
On Thu, Mar 19, 2009 at 4:03 PM, Sean McBride <sean at rogue-research.com>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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090319/b168b929/attachment.htm>
    
    
More information about the vtkusers
mailing list