[vtkusers] Mouse wheel events not working with vtkInteractorStyleUser

Elvis Stansvik elvis.stansvik at orexplore.com
Fri Jun 17 06:43:19 EDT 2016


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.

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


More information about the vtkusers mailing list