[vtkusers] Mouse wheel events not working with vtkInteractorStyleUser

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Jun 17 08:44:18 EDT 2016


2016-06-17 12:43 GMT+02:00 Elvis Stansvik <elvis.stansvik at orexplore.com>:

> Hi all,
>
> 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.
>
> But running this minimal test case:
>
> from vtk import vtkRenderWindow
> from vtk import vtkRenderWindowInteractor
> from vtk import vtkInteractorStyleUser
> from vtk import vtkCommand
>
> def onLeftButtonPressEvent(sender, event):
>     print('left button press')
>
> def onMouseWheelForwardEvent(sender, event):
>     print('wheel forward')
>
> interactorStyle = vtkInteractorStyleUser()
>
> interactorStyle.AddObserver(
>     vtkCommand.LeftButtonPressEvent,
>     onLeftButtonPressEvent)
>
> interactorStyle.AddObserver(
>     vtkCommand.MouseWheelForwardEvent,
>     onMouseWheelForwardEvent)
>
> renderWindow = vtkRenderWindow()
>
> interactor = vtkRenderWindowInteractor()
> interactor.SetRenderWindow(renderWindow)
> interactor.SetInteractorStyle(interactorStyle)
> interactor.Start()
>
> 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.
>

I'm starting to think that this is simply an accidental omission in
vtkInteractorStyleUser. Would you accept a patch to add support for
MouseWheelForwardEvent and MouseWheelBackwardEvent?

Elvis


> What should I do if I want to provide completely custom interaction from
> Python, and still be able to handle wheel events?
>
> Thanks in advance,
> Elvis
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160617/c90e06d6/attachment.html>


More information about the vtkusers mailing list