On May 19, 2011, at 1:23 PM, Martin Schürrer wrote:

> I want to highlight @mentions, #hashtags and links in an NSTextView as
> the user types. I've been thinking I'd implement this via the
> shouldChangeTextInRange delegate method.
> 
> My plan is as follows:
> I'm going to construct the new string (via
> stringByReplacingCharactersInRange:affectedCharRange
> withString:replacementString) and check the word (chain of chars
> separated by spaces on both ends) that's changed and highlight only
> this word.

I don't understand exactly what you are trying to do.

When you say "highlight," do you mean you want to change the text attributes of 
the word the user is currently typing?

If the answer is yes, why are you changing the contents of the string? I don't 
understand what you are replacing with what.

Generally, -doubleClickAtIndex: is the best way to get the range of a word (or 
"linguistic unit"). Looking for space characters can fail for any number of 
reasons (for example, some writing systems do not separate words with spaces).

NSTextView can already handle 
links._______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to