On Jul 20, 2009, at 9:48 PM, Daniel Jalkut wrote:

I'm trying to figure out how to prevent spell checking in my NSTextView from being applied to certain ranges within the text document.

[...]

It would be nice if NSSpellChecker offered a delegate relationship, something like "willMarkMispelledWordInRange:" ... where I could choose to have it keep quiet instead.

On 10.5 and later, there is public API which you can override in your NSTextView subclass:

- (void)setSpellingState:(NSInteger)value range:(NSRange)charRange;
// May be called or overridden to control setting of spelling and grammar indicators. Values are those listed for NSSpellingStateAttributeName. Calls the delegate method textView:shouldSetSpellingState:range:.

or the delegate variant:

- (NSInteger)textView:(NSTextView *)textView shouldSetSpellingState: (NSInteger)value range:(NSRange)affectedCharRange; // Delegate only. Allows delegate to control the setting of spelling and grammar indicators. Values are those listed for NSSpellingStateAttributeName.

If you need to support 10.4, perhaps you can use a custom layout manager which avoids setting the temporary spelling attributes for ranges you don't wish to display misspellings for.

Jim

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to