问题
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