Secure text .echosbullets not working for password field
You can accomplish what you want adding a second text field in top of your secure field. Add an IBAction to your check box to switch your fields isHidden property and copy the other textField stringValue and make it the first responder. Your implementation should look like something like this:
import Cocoa
class ViewController: NSViewController {
@IBOutlet weak var password: NSSecureTextField!
@IBOutlet weak var showPassword: NSTextField!
@IBOutlet weak var shwpswd: NSButton!
override func viewDidLoad() {
super.viewDidLoad()
shwpswd.state = .off
showPassword.isHidden = true
}
override func viewDidAppear() {
super.viewDidAppear()
password.window?.makeFirstResponder(password)
}
@IBAction func showHidePassword(_ sender: NSButton) {
showPassword.isHidden.toggle()
password.isHidden.toggle()
if !showPassword.isHidden {
showPassword.stringValue = password.stringValue
showPassword.becomeFirstResponder()
} else {
password.stringValue = showPassword.stringValue
password.becomeFirstResponder()
}
}
}
show/hide password sample
How to focus on a text field when opening an application?
You seem to be not over-riding the viewDidAppear that belongs to your NSViewController, but you are adding a new function on it's own.
Try using:
override func viewDidAppear() {
// Though the default implementation does nothing as of now,
// it is always safe to have the call to the super function in place,
// in case you plan to add sub-classes in between.
super.viewDidAppear()
addDomain.window?.makeFirstResponder(addDomain)
}
Related Topics
How to Run App in Simulator Xcode 6
How to Decrease a Value Using Fieldvalue in Firestore (Swift)
Render Images on iOS 14 Widgets
Undefined Symbol Objc_Class_$ When Creating iOS Framework
How to Parse JSON in JSON with Swiftyjson
Uicollectionviewcell Not Forcing Cell Size
Updating Switfui View When Coredata Changes
Decoding Dynamic JSON Structure in Swift 4
How to Disambiguate a Foreach Loop in Xcode with Swiftui
Swift Switch Char{ Case "\U{E2}:
Swift Access Array with Index Gives Following Error. Any Idea Why
Tabview, Tabitem: Running Code on Selection or Adding an Ontapgesture
How to Create Lazy Combinations
Swift:Program for Addition of 2 Numbers Using Closure