# How to disable right click Zoom function

**URL:** <https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782>\
**Category:** Feature requests\
**Created:** [May 25, 2021, 8:03am UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782 "2021-05-25T08:03:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luxiaoyang9999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luxiaoyang9999/32/9026_2.png) [@luxiaoyang9999](https://discourse.slicer.org/u/luxiaoyang9999)\
**Post date:** [May 25, 2021, 8:03am UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782/1 "2021-05-25T08:03:13Z")

</div>

Hello everyone,  
I want to implement my right click function in slicer. however, when I use observer to active my right click function, the default zoom function will also be activated and it cannot be closed.  
interactorStyle = slicer.app.layoutManager().sliceWidget(‘Red’).sliceView().sliceViewInteractorStyle()  
interactorStyle.SetActionEnabled(interactorStyle.Zoom, False)  
If I use above code to close zoom function, all relative functions will be closed, including ctrl+ mouse scrolling zoom function, this is function I need. Could anyone tell my how to only close the right click zoom function in slicer.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [May 26, 2021, 4:28am UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782/2 "2021-05-26T04:28:01Z")

</div>

You can fully reprogram all mouse and keyboard shortcuts in all the views, any way you want, just by using Python scripting. See examples in the [script repository](https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#customize-keyboard-mouse-gestures-in-viewers).

Adding a VTK event observer is generally not the right way to implement custom mouse&keyboard shortcuts (it would be too low level, so it would interfere with Slicer’s event routing). What would you like to achieve? Display a context menu if the user clicks in a view?

---

<div class="post-metadata">

**Author:** ![luxiaoyang9999](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/luxiaoyang9999/32/9026_2.png) [@luxiaoyang9999](https://discourse.slicer.org/u/luxiaoyang9999)\
**Post date:** [June 8, 2021, 2:36am UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782/3 "2021-06-08T02:36:49Z")

</div>

> [@lassoan](#):
>
> K event observer is generally not the right way to implement custom mouse&keyboard

I would like to create a right-click menu in a view. Moreover, when I use  
interactorStyle.SetActionEnabled(interactorStyle.Zoom, False)  
, I cannot get mouse position in view through crosshairNode like this

```
    event2 = slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent
    crosshairNode = slicer.util.getNode("Crosshair")
    obs2 = crosshairNode.AddObserver(event2, self.updateAnnotation_One_call)

```

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 9, 2021, 9:42pm UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782/4 "2021-06-09T21:42:17Z")

</div>

FYI, we’ll enable right-click menu in views about 2 weeks. You’ll be able to register your own menu items via subject hierarchy (the same way as all other menu items are registered in the Subject hierarchy tree, in Data module).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [March 21, 2023, 2:32am UTC](https://discourse.slicer.org/t/how-to-disable-right-click-zoom-function/17782/5 "2023-03-21T02:32:31Z")

</div>


