[vtkusers] add keypress event in vtkSeedWidget

David Cole DLRdave at aol.com
Wed Dec 17 08:17:29 EST 2014


A "git grep" of the current git 'master' branch shows that only
interactors and interactor styles actually invoke the KeyPress event:

$ git grep -E "Invoke.*KeyPressEvent"
GUISupport/Qt/QVTKInteractorAdapter.cxx:
iren->InvokeEvent(vtkCommand::KeyPressEvent, e2);
Interaction/Style/vtkInteractorStyleUser.cxx:
this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/Core/vtkInteractorStyle.cxx:
self->InvokeEvent(vtkCommand::KeyPressEvent,NULL);
Rendering/Core/vtkRenderWindowInteractor.cxx:
this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL/vtkCarbonRenderWindowInteractor.cxx:
me->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL/vtkCarbonRenderWindowInteractor.cxx:
me->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL/vtkCarbonRenderWindowInteractor.cxx:
me->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL/vtkWin32RenderWindowInteractor.cxx:
this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL/vtkXRenderWindowInteractor.cxx:
me->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL2/vtkAndroidRenderWindowInteractor.cxx:
this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL2/vtkWin32OpenGLRenderWindowInteractor.cxx:
this->InvokeEvent(vtkCommand::KeyPressEvent, NULL);
Rendering/OpenGL2/vtkXOpenGLRenderWindowInteractor.cxx:
me->InvokeEvent(vtkCommand::KeyPressEvent, NULL);

You will have to call AddObserver on the render window interactor, or
the current interactor style in order to receive the KeyPress event.


HTH,
David C.



On Tue, Dec 16, 2014 at 8:09 PM, Erkang Cheng <ekyaya at gmail.com> wrote:
> Hi all,
>
> I am playing with the vtkSeedWidget example, which is available from:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Widgets/SeedWidget
>
> I am stuck at how to add kepress event.
>
> I tried to add
>  seedWidget->AddObserver(vtkCommand::KeyPressEvent,seedCallback);
>
> right after the following lines:
>  seedWidget->AddObserver(vtkCommand::PlacePointEvent,seedCallback);
>   seedWidget->AddObserver(vtkCommand::InteractionEvent,seedCallback);
>
>
>  Another change is in class vtkSeedCallback::Execute
> I add one if-else blcok to capture keypress event.
>
> virtual void Execute(vtkObject*, unsigned long event, void *calldata)
>     {
>       if (event == vtkCommand::KeyPressEvent)
>        {
>           std::cout<<"key press"<<std::endl;
>        }
>
> ...
>
> }
>
>
> However, the widget can not capture keypress event.
>
> Could anyone share the idea to add customized event in vtkSeedWidget?
> Thanks.
>
> _______________________________________________
> 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://public.kitware.com/mailman/listinfo/vtkusers
>


More information about the vtkusers mailing list