How to disable right click zoom function individually?

Hello everyone
I tried to disable right click zoom function through

interactorStyle ='Red').sliceView().sliceViewInteractorStyle()
interactorStyle.SetActionEnabled(interactorStyle.Zoom, False)

but it can also lead to that I cannot observe mouse position change event in CrosshairNode

   self.mycrosshairNode = slicer.util.getNode('Crosshair')
   self.observationId_rightclick = self.mycrosshairNode.AddObserver(slicer.vtkMRMLCrosshairNode.CursorPositionModifiedEvent, self.mouse_move_event)

def mouse_move_event(self, observer, eventid):
    ras = [0, 0, 0]
    pos = self.interactor_red.GetEventPosition()

Could you tell me how to only disable right click zoom function?

Due to a small bug, you need to re-enable cursor position setting after you disable any action:

interactorStyle ='Red').sliceView().sliceViewInteractorStyle()
interactorStyle.SetActionEnabled(interactorStyle.Zoom, False)
interactorStyle.SetActionEnabled(interactorStyle.SetCursorPosition, True)

We’ll fix this soon in the Slicer Preview Release, se this re-enabling SetCursorPosition will no longer be necessary.


Thank you for your help, this code works.

Hello, Thank you for this usefull post.

How can i do the same things but for the 3D view ?

I believe like this:

interactorStyle =