• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Incremental parsing/highlighting in an NSTextView via shouldChangeTextInRange delegate method
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Incremental parsing/highlighting in an NSTextView via shouldChangeTextInRange delegate method


  • Subject: Re: Incremental parsing/highlighting in an NSTextView via shouldChangeTextInRange delegate method
  • From: Ross Carter <email@hidden>
  • Date: Fri, 20 May 2011 13:19:44 -0400

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@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

References: 
 >Incremental parsing/highlighting in an NSTextView via shouldChangeTextInRange delegate method (From: Martin Schürrer <email@hidden>)

  • Prev by Date: Re: Fire-and-forget controllers with blocks
  • Next by Date: Re: "Use them from only one thread at a time"
  • Previous by thread: Incremental parsing/highlighting in an NSTextView via shouldChangeTextInRange delegate method
  • Next by thread: Cocoa Touch (iPhone/iPad): List of notifications?
  • Index(es):
    • Date
    • Thread