# QVTKRenderWindowInteractor: switch right and middle button clicks

**URL:** <https://discourse.vtk.org/t/qvtkrenderwindowinteractor-switch-right-and-middle-button-clicks/15440>\
**Category:** Development\
**Created:** [March 29, 2025, 6:41pm UTC](https://discourse.vtk.org/t/qvtkrenderwindowinteractor-switch-right-and-middle-button-clicks/15440 "2025-03-29T18:41:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sapvi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sapvi/32/9874_2.png) [@sapvi](https://discourse.vtk.org/u/sapvi)\
**Post date:** [March 29, 2025, 6:41pm UTC](https://discourse.vtk.org/t/qvtkrenderwindowinteractor-switch-right-and-middle-button-clicks/15440/1 "2025-03-29T18:41:40Z")

</div>

I am using QVTKRenderWindowInteractor inside a PySide6 application. I would like to change the events of the right and middle (wheel) buttons to match the interactions of some other apps we are using.  
To be honest, I am not sure how to approach it. I have tried to connect some functions to `RightButtonClickEvent` but 1) this does not cancel the default event of zooming in/out, 2) I am not sure how to redirect the wheel button click here instead.

I have seen this in source code:

```auto
    def mousePressEvent(self, ev):
        ctrl, shift = self._GetCtrlShift(ev)
        repeat = 0
        if ev.type() == QtCore.QEvent.MouseButtonDblClick:
            repeat = 1
        self._Iren.SetEventInformationFlipY(ev.x(), ev.y(),
                                            ctrl, shift, chr(0), repeat, None)

        self._ActiveButton = ev.button()

        if self._ActiveButton == QtCore.Qt.LeftButton:
            self._Iren.LeftButtonPressEvent()
        elif self._ActiveButton == QtCore.Qt.RightButton:
            self._Iren.RightButtonPressEvent()
        elif self._ActiveButton == QtCore.Qt.MidButton:
            self._Iren.MiddleButtonPressEvent()

```

So it seems a bit to me as if all these events are under one function which then itself decides which button was pressed.

So do I need to somehow rewrite this whole event? Is it possible from Python? I definitely do not want to rewrite it in VTK & rebuild it just for this. Any workaround that can be applied? Or am I rather stuck with default controls if I do not want to mess with source?

---

<div class="post-metadata">

**Author:** ![sankhesh](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sankhesh/32/73_2.png) [@sankhesh](https://discourse.vtk.org/u/sankhesh)\
**Post date:** [April 3, 2025, 2:25pm UTC](https://discourse.vtk.org/t/qvtkrenderwindowinteractor-switch-right-and-middle-button-clicks/15440/2 "2025-04-03T14:25:02Z")

</div>

If you don’t want to zoom in when dragging the mouse, you could either override the [`mouseMoveEvent`](https://gitlab.kitware.com/vtk/vtk/-/blob/master/Wrapping/Python/vtkmodules/qt/QVTKRenderWindowInteractor.py#L586-596) and disable dollying or setup a custom interactor style that changes the behavior of interaction like in the example: [https://examples.vtk.org/site/Python/Interaction/MouseEvents/](https://examples.vtk.org/site/Python/Interaction/MouseEvents/)
