# Customize mouse button function

**URL:** <https://discourse.slicer.org/t/customize-mouse-button-function/4966>\
**Category:** Support\
**Created:** [December 5, 2018, 8:02am UTC](https://discourse.slicer.org/t/customize-mouse-button-function/4966 "2018-12-05T08:02:56Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 15, 2018, 4:50pm UTC](https://discourse.slicer.org/t/customize-mouse-button-function/4966/5 "2018-12-15T16:50:27Z")

</div>

> [@Maciej84](#):
>
> Care to point me in the right direction?

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:

```auto
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 😄

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.

---

_[View the full topic](https://discourse.slicer.org/t/customize-mouse-button-function/4966)._
