Getting more information from mouse pointer in 3D view

Hello slicer developers,

For my module I need the user to mouse click in the 3D view and see if it hits the 3D model. I found this example:

https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Get_scalar_values_at_surface_of_a_model

and this user that did something similar:

Is there also a way to read a mouse button event in the 3D view?
Is there another way to get the 2D or 3D mouse coordinates from the 3D view?

I think this might solve part of my problem:

This seems to hit the model in the 3D view and identify the slice coordinates? if so i need to capture the mouse click-events en calculate the RAS coords.

You can either use crosshair node or a markups node (in Slicer Preview Releases, when markups is in place mode, you can get the 3D coordinates of the mouse cursor from the markups node).

Hi Andras,
Yes using a markup node seems to work as well. For me it would work best if it is placed when a key is pressed or moushe click recorded in the 3D view. So i can remove it when the key or mouse button is released. Is there a way to record that in the 3D view?

When you click with the mouse then the markup is placed, which changes the state of that markup point. You can observe state changes similarly to position changes. If you don’t need to keep displaying the markup then you can delete it right after the point is placed.