[vtkusers] Event Handling with SelectionChangedEvent

Jeff Baumes jeff.baumes at kitware.com
Tue Feb 10 08:38:04 EST 2009


Hi Aytekin,

Based on previous emails, I believe your "selections" object is a
vtkDataRepresentation, which does not emit any key press events (or
mouse events). These events are emitted by the interactor style. So
you'd do something like

win->GetInteractor()->GetInteractorStyle()->AddObserver(vtkCommand::KeyPressEvent,
callback);

where "win" is your vtkRenderWindow instance. This should be done
after the SetupRenderWindow call.

Jeff

On Mon, Feb 9, 2009 at 11:11 AM, Aytekin Vargun <varguna at gmail.com> wrote:
> Hi,
> I am currently having problems with my event handler and would appreciate if
> anybody suggests me  a solution.
>
> The ProcessVertexSelection (user defined) method is activated when some
> selections are made (based on SelectionChangeEvent). Everything is good upto
> this point. Here is the code for this:
>
> edgePicked->SetCallback(network->ProcessVertexSelection);
> edgePicked->SetClientData((void *)static_cast<vtkSelectionLink*>(edgeLink));
> selections->AddObserver(vtkCommand::SelectionChangedEvent, edgePicked);
>
> This part works and I can get the selections. Now I want to add another
> functionality: The user may want to delete the current selections by using
> key 'd' or "delete" whichever is simple to implement. I know that GetKeySym
> can be used to get key symbol. However, if I add the following code to
> activate another method to do deletions, the event handler ignores it. It
> never activates the method which is named as EVTDelete (in my code) where I
> plan to check which key is used.
>
> delPicked->SetCallback(network->EVTDelete);
> delPicked->SetClientData((void *)static_cast<vtkSelectionLink*>(edgeLink));
> selections->AddObserver(vtkCommand::KeyPressEvent, delPicked);
>
> Why doesn't my event handler listen do the keypresses other than the default
> ones?
> Thanks a lot.
> Aytekin
>
> --
> My web page: http://www.cs.rpi.edu/~vargua
>
> _______________________________________________
> 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
>
>



-- 
Jeff Baumes, Ph.D.
R&D Engineer, Kitware Inc.
(518) 371-3971 x132
jeff.baumes at kitware.com



More information about the vtkusers mailing list