Issue #588

class FocusAwareTextField: NSTextField {
    var onFocus: () -> Void = {}
    var onUnfocus: () -> Void = {}

    override func becomeFirstResponder() -> Bool {
        onFocus()
        let textView = window?.fieldEditor(true, for: nil) as? NSTextView
        textView?.insertionPointColor = R.nsColor.action
        return super.becomeFirstResponder()
    }

    override func resignFirstResponder() -> Bool {
        onUnfocus()
        return super.resignFirstResponder()
    }
}