Is there any callback for the mouse click when adding a new markup?

Hello, I am developing a new application for 3D Slicer, however I cannot find a resolution to my problem. I am running a way to add control points via mouse click, the way I found in the repository script.

selectionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLSelectionNodeSingleton")
interactionNode = slicer.mrmlScene.GetNodeByID("vtkMRMLInteractionNodeSingleton")
placeModePersistence = 1
# mode 1 is Place, can also be accessed via slicer.vtkMRMLInteractionNode().Place

Would it be possible to associate some callback for when a new control point is added?
Thank you all for your attention.

I think you’re looking for the PointPositionDefinedEvent. slicer.vtkMRMLMarkupsNode.PointPositionDefinedEvent

1 Like

It’s worked, thank you!!
I made a new function:

def AddNewMarkup(self, caller, event):
        markupsNode = caller
        sliceView = markupsNode.GetAttribute("Markups.PointPositionDefinedEvent")
        movingMarkupIndex = markupsNode.GetDisplayNode().GetActiveControlPoint()
        addingMarkup = slicer.vtkMRMLMarkupsNode.PointAddedEvent 
        if addingMarkup >= 0:
            newMarkup = f"fiducial_{movingMarkupIndex+1}"

and I call it by:
self.tnode.AddObserver(slicer.vtkMRMLMarkupsNode.PointPositionDefinedEvent, self.AddNewMarkup)