Turn off OS X 10.7 Lion's “auto-correct” feature programmatically?

不想你离开。 提交于 2019-12-20 04:16:34

问题


OS X Lion has an iPhone-like autocorrect feature as you're typing.

This feature interferes with my typing app. The people using my app would not want it turned on at all, system wide. I need to turn off all auto-correct off for all apps, not just in my own NSTextField.

Is there any way for me to check/set the global/system auto-correct feature to OFF? Or am I stuck basically providing a guided tutorial for how to turn it off?

Solution must be legal for the Mac App Store.


回答1:


Is this in an NSTextView? If so, there are several methods available to alter the correction behavior:

- (void)setAutomaticSpellingCorrectionEnabled:(BOOL)flag
- (void)setAutomaticTextReplacementEnabled:(BOOL)flag

Please try those, they should be what you are looking for.




回答2:


Finally, there is additional API to support the new global user preference settings for automatic text replacement and spelling correction. NSTextView now by default will keep track of and follow these settings automatically, but applications using NSTextView can override that by programmatically using existing NSTextView methods such as -setAutomaticTextReplacementEnabled: and -setAutomaticSpellingCorrectionEnabled: to control an individual text view's settings. The new API is primarily for non-text view clients who wish to keep track of the settings for themselves, using the NSSpellChecker class methods to determine their values, and optionally also notifications to determine when the settings have changed.

+ (BOOL)isAutomaticTextReplacementEnabled;
+ (BOOL)isAutomaticSpellingCorrectionEnabled;

NSString * const NSSpellCheckerDidChangeAutomaticSpellingCorrectionNotification;
NSString * const NSSpellCheckerDidChangeAutomaticTextReplacementNotification;

https://developer.apple.com/library/mac/#releasenotes/Cocoa/AppKit.html



来源:https://stackoverflow.com/questions/8144784/turn-off-os-x-10-7-lions-auto-correct-feature-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!