<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2016-06-17 12:43 GMT+02:00 Elvis Stansvik <span dir="ltr"><<a href="mailto:elvis.stansvik@orexplore.com" target="_blank">elvis.stansvik@orexplore.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div>Hi all,<br><br></div>From what I've read, vtkInteractorStyleUser is still the canonical way to do completely custom interaction behavior from Python, by observing the events of the interactor.<br><br></div>But running this minimal test case:<br><br>from vtk import vtkRenderWindow<br>from vtk import vtkRenderWindowInteractor<br>from vtk import vtkInteractorStyleUser<br>from vtk import vtkCommand<br><br>def onLeftButtonPressEvent(sender, event):<br>    print('left button press')<br><br>def onMouseWheelForwardEvent(sender, event):<br>    print('wheel forward')<br><br>interactorStyle = vtkInteractorStyleUser()<br><br>interactorStyle.AddObserver(<br>    vtkCommand.LeftButtonPressEvent,<br>    onLeftButtonPressEvent)<br><br>interactorStyle.AddObserver(<br>    vtkCommand.MouseWheelForwardEvent,<br>    onMouseWheelForwardEvent)<br><br>renderWindow = vtkRenderWindow()<br><br>interactor = vtkRenderWindowInteractor()<br></div></div></div></div></div></blockquote><div><br></div><div>Observing the events directly on the interactor works of course. E.g. if I add here<br><br>interactor.AddObserver(<br>    vtkCommand.MouseWheelForwardEvent,<br>    onMouseWheelForwardEvent)<br><br></div><div>then it works. So it's just the vtkInteractorStyleUser which seems to lack support for wheel events.<br><br></div><div>But observing the interactor directly like this completely spoils the point of using interactor styles in the first place (being able to easily switch between styles).<br><br></div><div>Elvis<br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div><div><div>interactor.SetRenderWindow(renderWindow)<br>interactor.SetInteractorStyle(interactorStyle)<br>interactor.Start()<br><br></div>It seems that wheel events are not supported by vtkInteractorStyleUser? Scrolling the wheel forwards prints nothing, while pressing the left mouse button prints "left button press" as expected.<br><br></div>What should I do if I want to provide completely custom interaction from Python, and still be able to handle wheel events?<br><br></div>Thanks in advance,<br></div>Elvis<br><br></div>
</blockquote></div><br></div></div>