I\'ve setup an NSTextField with text color as white, and the background color as (black despite not rendering the background color, so its transparent). All in
If you use Objective-C runtime selector capture combined with uliwitness's solution, you can achieve it without subclassing NSTextField, here I use RxCocoa's methodInvoked as an example:
import Cocoa
import RxCocoa
extension NSTextField {
func withCursorColor(_ color: NSColor) {
rx.methodInvoked(#selector(becomeFirstResponder))
.subscribe(onNext: { [unowned self] _ in
guard let editor = self.currentEditor() as? NSTextView else { return }
editor.insertionPointColor = color
})
.disposed(by: rx.disposeBag)
}
}