Last active
April 26, 2021 11:29
-
-
Save esmitt/7ca96193f2c320ba438e0453f9136c20 to your computer and use it in GitHub Desktop.
VTK way using lambda function in C++ to detect when a key was pressed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vtkNew<vtkCallbackCommand> keypressCallback; | |
auto KeypressCallbackFunction = [](vtkObject* caller, long unsigned int vtkNotUsed(eventId), void* clientData, void* vtkNotUsed(callData)) { | |
vtkRenderWindowInteractor* iren = static_cast<vtkRenderWindowInteractor*>(caller); | |
std::cout << "Pressed: " << iren->GetKeySym() << std::endl; | |
}; | |
keypressCallback->SetCallback(KeypressCallbackFunction); | |
renderWindowInteractor->AddObserver(vtkCommand::KeyPressEvent, keypressCallback); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment