Question
In some applications, such as mail clients or Twitter clients, I find myself typing away at something, everything looks good and right when I press the send/Tweet button the text view automatically corrects the last word to an incorrect spelling. Obviously at that point I waited just the wrong amount of time after finishing typing before sending it so the spell checking was still going on.
I guess the first question here really should be what do you think about removing that functionality? Because on the other hand I'm sure that exact same thing happens to people but it actually fixes the spelling of the last word as opposed to messing it up. Otherwise if you think this is a valid idea is there a way to disable automatic spelling correction when a NSTextView
loses focus?
What I've looked at:
This question on how to deal with spelling stuff in
NSTextView
sThis question on turning off spell checking all together.
NSSpellChecker
specifically it's Auto Spelling Correction methods (I really thought this would get me somewhere) I finished wondering why aNSSpellCheckerDelegate
doesn't existThis question about
NSSpellChecker
's misleading (read the comments)NSNotification
sNSTextCheckingTypes
(at the bottom) specificallyNSTextCheckingTypeCorrection
This question about doing spell checking in general
NSTextView
specifically the 'Working With the Spelling Checker' and 'Text Checking and Substitutions' methodsThis question just about turning the functionality on and off
The Spell Checking Programming Topics which really only talks about non-automatic spell checking
NSTextViewDelegate
specifically the 'Working With the Spelling Checker' methods
What I actually tried (in Xcode in an empty project)
Implementing the
NSTextDelegate
textShouldBeginEditing:
andtextShouldEndEditing:
and inside of calling[self.textView setAutomaticSpellingCorrectionEnabled:true];
and[self.textView setAutomaticSpellingCorrectionEnabled:false];
respectively (at first I also calledNSTextView
'ssetAutomaticTextReplacementEnabled:
but that's just for user settings like (c) to the copyright symbol)In the same
textShouldBeginEditing:
andtextShouldEndEditing:
(from above) setting theNSTextView
'senabledTextCheckingTypes
toNSTextCheckingAllTypes
andNSTextCheckingAllTypes - NSTextCheckingTypeCorrection
respectively.Subclassing
NSTextView
and implementingbecomeFirstResponder
andresignFirstResponder
and in them changing the same properties as above.Calling
NSSpellChecker
methods from eitherresignFirstResponder
ortextShouldEndEditing:
(this works with[[NSSpellChecker sharedSpellChecker] dismissCorrectionIndicatorForView:self];
) to hide the popup but it still corrects the spelling)
Example
I've noticed this functionality in Tweetbot you can test it using foriegn vs foreign. If you type it in and Tweet it while the bubble is still up it will Tweet the incorrect spelling.