Customize mouse button function

Note that I’m not saying this is a good idea, but if you want to experiment, you can do something like this in the python console:

lm = slicer.app.layoutManager()
rw = lm.sliceWidget('Red').sliceView().renderWindow()
style = vtk.vtkInteractorStyleUser()
rw.GetInteractor().SetInteractorStyle(style)
def cb(a,b):
  print(a,b)
style.AddObserver("AnyEvent", cb)

From there you can change the callback function (cb) to do whatever you want, using the Slicer code linked above as a guide. Of course a lot of things will break if you do this :smile:

I suppose if this is becomes a common enough request we could add hooks to do things like easily filter events or remap key/mouse bindings. Of course we’re reluctant because support and documentation could be much harder if everyone starts using different buttons.

1 Like