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

Michael Jackson mike.jackson at bluequartz.net
Thu Mar 19 21:17:40 EDT 2009


But aren't there times when you want to make the OpenGL context the  
current context but NOT bring the window to the front? Your code would  
do that, which might be a bit annoying.

  The code I submitted is designed for _you_ to put in _your_ code and  
NOT into any of the vtk code. Well maybe the cone examples and stuff  
like that but NOT the render classes.

  I also may be way wrong on that but last time I ran my code the code  
worked just fine with keyboard events and all.

---
Mike Jackson                 www.bluequartz.net



On Mar 19, 2009, at 7:19 PM, Darren Weber wrote:

>
> 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
>
>
>
> _______________________________________________
> 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




More information about the vtkusers mailing list