使用 Swift 在 NSTextField 中拼写
Spelling in NSTextField with Swift
如何使用 swift 检查 NSTextField
的拼写?我已经在使用 controlTextDidChange
来验证文本。 This solution 似乎提到将第一响应者转换为 NSTextView
但我不确定 swift 使用强制是否可行。我知道如果我改成 NSTextView
会更容易,但如果可能的话我想避免这种情况。
这应该能帮到你。
// Focus TextField
phraseTextField.becomeFirstResponder()
// Enable Continous Spelling
let textView: NSTextView = (self.window!.firstResponder as! NSTextView)
textView.continuousSpellCheckingEnabled = true
改编自:How do I enable spell checking within an NSTextField on Mac OS X?
在其他情况下,将 NSTextField
s 更改为 NSTextView
s 可能会更好。只需使用 "Text View"(在对象库中搜索 NSTextView),拼写检查将默认打开。据我所知,NSTextFields 在某些情况下根本不支持拼写检查。
如何使用 swift 检查 NSTextField
的拼写?我已经在使用 controlTextDidChange
来验证文本。 This solution 似乎提到将第一响应者转换为 NSTextView
但我不确定 swift 使用强制是否可行。我知道如果我改成 NSTextView
会更容易,但如果可能的话我想避免这种情况。
这应该能帮到你。
// Focus TextField
phraseTextField.becomeFirstResponder()
// Enable Continous Spelling
let textView: NSTextView = (self.window!.firstResponder as! NSTextView)
textView.continuousSpellCheckingEnabled = true
改编自:How do I enable spell checking within an NSTextField on Mac OS X?
在其他情况下,将 NSTextField
s 更改为 NSTextView
s 可能会更好。只需使用 "Text View"(在对象库中搜索 NSTextView),拼写检查将默认打开。据我所知,NSTextFields 在某些情况下根本不支持拼写检查。