[vtkusers] How to activate KeyPress Events invtkXRenderWindowInteractor?

Luca Pallozzi Lavorante lplavorante at gmail.com
Fri Mar 30 07:33:57 EDT 2007


Hi Vidyadhar, thank you for you replay.
Yesterday there has been another thread of messages dealing with the same
question and, again, the Focus issue has been raised.
I was trying to implement picking using the ´p´ key, but then I resolved
using mouse events. As to the exit event caused by the `q` and `e` keys,
can´t it be trapped using an observer on the Interactor?

Thank you

     Luca

On 3/30/07, vidyadhar <vidyadhar at lucidindia.net> wrote:
>
>  Hi,
> I use win32 only so cannot be sure about other windowing environments. In
> win32, mouse events go to window under mouse cursor so render window,
> standalone or parented to some other window receives the mouse events.
> Keyboard events go to that window which has keyboard focus. This could be
> dialog window parent of render window or some deeper nesting (in my case
> nesting is very deep, using MDI window with user controls parenting render
> window). For this reason, keyboard events are processed in stand alone vtk
> window but not if it is parented. Some mechanism has to be set to pass
> keypress events from container upto render window interactor. This is tricky
> and I have not tried it beyond direct parentage case. A word of caution if
> you decide to try this event forwarding. Pressing 'Q', 'q', 'E' and 'e' key
> which are passed to interactor can cause the entire application to close
> down (on win32 the interactor send quit message to OS).
> HTH
> vidyadhar
>
> ----- Original Message -----
> *From:* Luca Pallozzi Lavorante <lplavorante at gmail.com>
> *To:* vtkusers at vtk.org
> *Sent:* Thursday, March 29, 2007 3:43 AM
> *Subject:* [vtkusers] How to activate KeyPress Events
> invtkXRenderWindowInteractor?
>
> Hi everybody,
> I am trying to use a KeyPressEvent in my application using some test
> callback. I have followed the procedure listed below,  but when I press a
> key nothing happens.
> Could someone please tell me if I am missing something?
> Thank you very much for your help.
>
>        Luca
>
> Code:
>
> vtkXRenderWindowInteractor *iren = vtkXRenderWindowInteractor::New();
>
> vtkCallbackCommand *keyPressCB = vtkCallbackCommand::New();
>   keyPressCB->SetClientData(iren);
>   keyPressCB->SetCallback (keyPressCallback); //  keyPressCallback is
> created elsewhere. It prints a message.
>
> vtkInteractorStyleTrackballCamera *styleTrackball =
> vtkInteractorStyleTrackballCamera::New();
>   styleTrackball->AddObserver(vtkCommand::KeyPressEvent, keyPressCB);
>
> iren->SetInteractorStyle(styleTrackball);
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070330/4cfeec8e/attachment.htm>


More information about the vtkusers mailing list