I am calling the drawMarker function from the mouseMoved function of the view by passing the CGPoints of the event.locationInWindow. The below code does not work. Appreciate any suggestions to be able to draw the markers where the mouse has moved on a view. I guess the issue is with the NSGraphicsContext that I cannot figure out.
private func drawMarker(x: CGFloat, y: CGFloat, markerSize: CGFloat, markerColor: NSColor, markerOpacity: CGFloat = 0.5){
guard let aContext = NSGraphicsContext.current else { return }
aContext.saveGraphicsState()
if graphType == .barGraph { return }
let circleLayer = NSBezierPath(ovalIn: CGRect(x: x - (markerSize/2), y: y - (markerSize/2), width: markerSize, height: markerSize))
markerColor.withAlphaComponent(markerOpacity).set()
circleLayer.fill()
circleLayer.stroke()
aContext.restoreGraphicsState()
}