onmyway133 / blog

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

How to check NSTextField is first responder #961

Open onmyway133 opened 10 months ago

onmyway133 commented 10 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
    }
}