onmyway133 / blog

🍁 What you don't know is what you haven't learned
https://onmyway133.com/
MIT License
669 stars 33 forks source link

How to check NSTextField is first responder #961

Open onmyway133 opened 5 months ago

onmyway133 commented 5 months ago

NSTextField uses NSFieldEditor under the hood, you can check currentEditor if it is the firstResponder

extension NSTextField {
    var isFirstResponder: Bool {
        currentEditor() == window?.firstResponder
    }
}