Hi, I've been making good progress with learning how to use NSTextFieldDelegate with NSTextField, but I'm struggling with how to use it with NSSecureTextField. Can anyone point me in the right direction? I need to be able to grab the stringValue and work with it when the return key is pressed. The code below works fine for an NSTextField. I obviously need to use a different function, or a different responder type perhaps?
func control(_ control: NSControl, textView: NSTextView, doCommandBy commandSelector: Selector) -> Bool { if (commandSelector == #selector(NSResponder.insertNewline(_:))) {
guard let sender = control as? NSSecureTextField else {return false}
if sender.tag == 1 { print("It equals 1") } if sender.stringValue != "" { print("field is not empty") }
self.view.window?.makeFirstResponder(sender.nextKeyView) return true }
return false }