[vtkusers] Detect which key was released on vtkCommand::KeyReleaseEvent

Girault, Alexis girault at email.unc.edu
Tue Jul 30 11:48:14 EDT 2013


Hey all,

I would like to interact with a QVTKwidget when I release the ESC key.

I am able to add an observer on the Interactor of my QVTKwidget this way, that calls the function UnselectWidget() anytime I release a key if i was interacting with my QVTKwidget :
meshWidget->GetInteractor()->AddObserver(vtkCommand::KeyReleaseEvent, this, &ShapePopulationViewer::UnselectWidget);

I'd like to verify if the key that was released was ESC, just like this line for Ctrl  :
if(selectedInteractor->GetControlKey()==1)

If it is easier it can be when I press ESC (KeyPressedEvent) instead, but I still need to identify the Key.

I tried to use the QT function this way instead, but the function is only called when I am in the main window, and is not recognized when I am interacting with the QVTKwidget :
void myclass::keyPressEvent(QKeyEvent *event){
    if((event->key() == Qt::Key_Escape)){
    [...]
}}

Any idea? Thank you. Alexis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130730/bb092302/attachment.htm>


More information about the vtkusers mailing list