[vtkusers] Mouse wheel events not working with vtkInteractorStyleUser

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Jun 17 06:47:50 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()
>

Observing the events directly on the interactor works of course. E.g. if I
add here

interactor.AddObserver(
    vtkCommand.MouseWheelForwardEvent,
    onMouseWheelForwardEvent)

then it works. So it's just the vtkInteractorStyleUser which seems to lack
support for wheel events.

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).

Elvis

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.
>
> 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/23eea305/attachment.html>


More information about the vtkusers mailing list