NSTextView, spell checking and temporary attributes
NSTextView, spell checking and temporary attributes
- Subject: NSTextView, spell checking and temporary attributes
- From: Martin Hewitson <email@hidden>
- Date: Mon, 02 Jan 2012 19:20:46 +0100
Dear list,
I have an NSTextView subclass which I've set up to highlight matching words in view. So if the user highlights a word, all matching words are highlighted. I'm doing the highlighting using a temporary attribute on the layout manager: NSBackgroundColorAttributeName.
In order for this to work, I first remove this attributed in the visible range of text:
[[self layoutManager] removeTemporaryAttribute:NSBackgroundColorAttributeName forCharacterRange:visibleRange];
This has the unfortunate side-effect of removing the red squiggly lines which indicate misspelled words.
So, I was trying to think of ways out of this. I could cycle through all temporary attributes in view and only remove those where NSBackgroundColorAttributeName is the color of my highlighting. This seems a bit heavy.
I was wondering if I could do the removal and then get the text view to re-highlight the misspelled words, but I couldn't find a way to make it do that.
Any ideas?
Best wishes
Martin_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden