Right Button Press on Markups Fiducial

Hello,

I am looking to implement a context menu similar to this one from the script repository - however, I’d like to be able to use a right click instead of a left click with the mouse.

I know that I can do something like the below to create a menu when I right click, but this allows the menu to pop up even if a markup fiducial is not clicked, and doesn’t allow me to pass the fiducial ID through the callData to update the menu accordingly.

layoutManager = slicer.app.layoutManager()
redRenderWindow = layoutManager.sliceWidget('Red').sliceView().renderWindow()
style = vtk.vtkInteractorStyleUser()
redRenderWindow.GetInteractor().SetInteractorStyle(style)
style.AddObserver(vtk.vtkCallbackCommand.RightButtonPressEvent, self.analysisWidget.markupCallback)

Markups are completely reworked in recent 4.11 versions. In these versions you can easily change/add mapping of right-click to an arbitrary markup node event (that you can observe from your module). This is not exposed on any external API though, so you need to change the source code of Slicer and rebuild.