12345678910111213141516171819202122232425 |
- //
- // FocusAwareSecureTextField.swift
- // PDF Reader Pro
- //
- // Created by lizhe on 2023/10/23.
- //
- import Cocoa
- class FocusAwareSecureTextField: NSSecureTextField {
- var onFocus: () -> Void = {}
- var onUnfocus: () -> Void = {}
- override func becomeFirstResponder() -> Bool {
- onFocus()
- let textView = window?.fieldEditor(true, for: nil) as? NSTextView
- textView?.insertionPointColor = NSColor.km_init(hex: "#252629")
- return super.becomeFirstResponder()
- }
- override func resignFirstResponder() -> Bool {
- onUnfocus()
- return super.resignFirstResponder()
- }
- }
|