Ho to check for left button single click event vs click and drag event

I have a view with a vtkInteractorStyleTrackballCamera interactor. When you drag the mouse (left click and drag) it rotates the object. This is good. Now I want to return the mouse coordinates when the user does a single left button click and release.

At the moment, when I add a vtkCallbackCommand with the vtkCommand::KeyPressEvent the rotational ability of the object gets disabled. Any thoughts?

Hi, Daniel,

Do you extend vtkInteractorStyleTrackballCamera? If so, you need to forward the event to the superclass: vtkInteractorStyleTrackballCamera::OnLeftButtonDown(); in your class if you wish to maintain the original behavior in addition to the one of your code.



Hi Paulo,

Thanks for your response. I have managed to find a solution to my problem. Not sure if it is the best one but it works.

I prefer to use observers then I do not have to do the whole inheritance thing. I added a callback method to my vtkInteractorStyleTrackballCamera object using the vtkCommand::LeftButtonPressEvent and the vtkCommand::LeftButtonReleaseEvent (on the same method).

I then record the mouse pointer location on the LeftButtonPressEvent and compare it to when the mouse button is released (LeftButtonReleaseEvent). If they match I then do my stuff. That is it.


1 Like