How to tell if mouse is over a viewer

How can you tell if you’re on the viewer? Is there something you can test so that certain functionality is disabled when the mouse is not hovered over the viewer?

You can get the current view ID and position in view and RAS coordinate systems via the crosshair singleton node. See examples in the script repository.

I see. I am currently using a crosshair node to get information from a viewer when the mouse hovers over the scan. However, after I move my mouse off of the scan/view area, the program crashes. Would this likely be something to do with the crosshair node? Or an interactor?

This only started happening after I began using the crosshair node. Specifically, after I call a line that uses ->GetCursorPositionXYZ(xyz);

I could not reproduce the crash using the latest Slicer Preview Release. If you can create a small standalone example that reproduces the problem then I can investigate.