Customize mouse button function


(Maciej Debowski) #1

Operating system: Win10
Slicer version: 4.9.0
Expected behavior: Is it possible to change the default function of the mouse buttons? In my clinical software right click and drag scrolls through the volume, while in 3Dslicer it zooms. Would be great to be able to change these presets, rather than having to get used to several different interfaces. Like wise, left-click and drag changes the windowing - which I hate because once I find a window that I’m happy with I generally don’t want it to change!


(Steve Pieper) #2

Hi -

Right now these functions are hard coded in the interactor style code. It Should be possible to override this behavior with some python scripting, but there’s no GUI for it. If you are interested in doing some programming let us know if you want ideas of how to get started.

One thing that you can do is lock the window/level for a Volume using the Volumes Module. Not exactly what you asked for but it might help.

Best,
Steve


(ibr_ex@yahoo.com) #3

Just a suggestion for future feature: to have number of customizations as themes that makes the interface looks and behaves similar to popular tools. I know some radiologists who do not like to use Slicer even for simple task like manual segmentation because it is not similar to what they use.


(Maciej Debowski) #4

Thanks Steve. So looks like those mouse functions are fairly simply defined in that config file. Was hoping that I could simply edit this file in notepad but clearly it’s not that simple! Can’t even find such a file in my Slicer install directory.

Care to point me in the right direction?


(Steve Pieper) #5

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.