Not sure about what’s available from Kitware’s C# VTK. If you’re doing it without extending the interactor style, it is best to listen to the interactor for events and then forward the event to the interactor style.
Here’s an example in C++, it should apply to Python and C# assuming VTK C# exposes the enums from vtkCommand
and functions from interactor style.
void OnLeftButtonDown(....)
{
// ...
// switch style could be a special case, so just to be safe, let's handle it.
auto* style = vtkInteractorStyle::SafeDownCast(interactor->GetInteractorStyle());
if (auto* switchableStyle = vtkInteractorStyleSwitch::SafeDownCast(style))
{
switchableStyle->GetCurrentStyle()->OnLeftButtonDown();
}
else
{
style->OnLeftButtonDown();
}
}
void OnLeftButtonUp(....)
{
// ...
// switch style could be a special case, so just to be safe, let's handle it.
auto* style = vtkInteractorStyle::SafeDownCast(interactor->GetInteractorStyle());
if (auto* switchableStyle = vtkInteractorStyleSwitch::SafeDownCast(style))
{
switchableStyle->GetCurrentStyle()->OnLeftButtonUp();
}
else
{
style->OnLeftButtonUp();
}
}
interactor->AddObserver(vtkCommand::LeftButtonPressEvent, OnLeftButtonDown);
interactor->AddObserver(vtkCommand::LeftButtonReleaseEvent, OnLeftButtonUp);