Using NSTextFieldDelegate with NSSecureTextField

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  }

Okay. It can be accessed by creating an action, but that seems kind of clumsy. I'm going with that, but if anyone knows how to access the stringValue via a delegate method please let me know. I'd love to know if it's possible.

Using NSTextFieldDelegate with NSSecureTextField
 
 
Q