Last active
April 22, 2024 17:33
-
-
Save usagimaru/0cf7cb2c22c75493e03363f682cdaba6 to your computer and use it in GitHub Desktop.
An extension to check if NSTextField / NSSearchField is the first responder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
extension NSView { | |
var isFirstResponder: Bool { | |
window?.firstResponder == self | |
} | |
} | |
extension NSTextField { | |
override var isFirstResponder: Bool { | |
if let fieldEditor = currentEditor() { | |
return fieldEditor == window?.firstResponder | |
} | |
return false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment