如何使用swift检查NSTextField
的拼写?我已经在使用controlTextDidChange
来验证文本。 This solution似乎提到第一响应者作为NSTextView
,但我不确定这是可能的迅速使用强制。我知道如果我更改为NSTextView
,这会更容易,但如果可能,我想避免这种情况。使用Swift在NSTextField中拼写检查
回答
这应该会帮助你。
// 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
秒。只需使用“文本视图”(在对象库中搜索NSTextView),拼写检查将默认打开。尽我所知,NSTextFields在某些情况下根本不支持拼写检查。
我认为这种方法在大多数情况下都能正常工作,但为了增加复杂性,它是NSStatusBar应用程序 - 没有菜单。所以在我的情况下,上面的代码只是挂起了应用程序。 – glenstorey
@glenstorey我修改了我的答案,让我知道它是否有帮助! – owlswipe
嘿 - 所以我在Google搜索后回到了这个问题,结果证明你的解决方案工作得很好(当你在viewDidLoad中完成.becomeFirstResponder的时候,现在是显而易见的原因)。非常感谢! – glenstorey
- 1. 如何在Mac OS X的NSTextField中启用拼写检查?
- 2. 在PHP中拼写检查
- 3. 拼写检查
- 4. 在TextView中禁用拼写检查
- 5. GWT拼写检查
- 6. javascript拼写检查
- 7. hunspell拼写检查
- 8. WPF拼写检查
- 9. Iphone拼写检查
- 10. 拼写检查textfield
- 11. Aptana拼写检查
- 12. c中的拼写检查#
- 13. StackOverflow使用什么拼写检查?
- 14. gedit使用哪种拼写检查器?
- 15. 如何使用solrj做拼写检查
- 16. 要使用哪种拼写检查器?
- 17. 使用lucene的拼写检查程序
- 18. 使用jOrtho拼写检查器
- 19. 如何使用Casperjs检查拼写?
- 20. 在Tortoise SVN中进行拼写检查
- 21. 在Visual Studio 2005中拼写检查
- 22. 在Nutch 1.0中的拼写检查器
- 23. 在h:inputtextarea中使用jQuery禁用拼写检查
- 24. 检查拼写检查程序C
- 25. Solr的拼写检查
- 26. 拼写检查的文献?
- 27. TeXlipse拼写检查配置
- 28. 安卓拼写检查
- 29. IE6的拼写检查器?
- 30. 列拼写检查VBA Excel
所以我在几个月前帮你出这一点,而现在有人路过发布的评论,我不知道我回答完全。你能帮他解决问题吗? (谢谢!) – owlswipe
嗨@JohnRamos - 没问题! – glenstorey
谢谢!非常感激。 – owlswipe