now draw a line inside and nsview that is inside another nsview
it gets messy quickly but I suspect Swift has better facilities for dealing with the true location of such an deeply nested embedded view
yeah that doesn’t work, and even if it did, it would not be applicable to this app, seeing as the coordiantes are not know until runtime, plus I need to have complete control of the z-order, where this method would draw the line(s) under everthing else on the window, but thanks
here is my solution… seems to work in all use cases
open class uxLINE: ux$Shape {
var pt1 = CGPoint.zero
var pt2 = CGPoint.zero
@MainActor required public init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
public override init(frame:CGRect=CGRect.zero) {
let oldFrame = frame
super.init(frame:CGRect(x:0,y:0,width:max(frame.origin.x,frame.size.width),height:max(frame.origin.y,frame.size.height)))
pt1 = oldFrame.origin
pt2 = CGPoint(x:oldFrame.size.width,y:oldFrame.size.height)
constructor()
}
// MARK: OBJECT DECLARATION
public override func draw(_ rect: CGRect) {
// unlike other shapes, LINE uses CGRECT to store the line ENDS
super.draw(rect)
let context: CGContext = NSGraphicsContext.current!.cgContext
context.setStrokeColor(lineColor.cgColor)
context.setLineWidth(borderWidth)
context.setLineDash(phase: 0,lengths: penStyle.mask)
context.move(to: pt1)
context.addLine(to: pt2)
context.strokePath()
}
}