• 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: getting visible character range
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting visible character range


  • Subject: Re: getting visible character range
  • From: Douglas Davidson <email@hidden>
  • Date: Mon, 6 Feb 2006 09:25:07 -0800


On Feb 5, 2006, at 11:07 AM, Aleaxander Cohen wrote:

I'm trying to get the visible character range from a NSTextView and then, from the first visible character, move back to the first white space, and from the last character, move to the next whitespace. How can i get that range?


1) Get the visibleRect of the view.
2) Convert it to container coordinates by subtracting the textContainerOrigin from the rect's origin.
3) Ask the layout manager for the glyphRangeForBoundingRect:inTextContainer:.
4) Convert the glyph range to a character range with characterRangeForGlyphRange:actualGlyphRange:.
5) I'm not sure exactly what you want when you speak of whitespace, but you might consider nextWordFromIndex:forward:.


Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >getting visible character range (From: Aleaxander Cohen <email@hidden>)

  • Prev by Date: Re: Remove indicatorImage from table column
  • Next by Date: Authoring application Help
  • Previous by thread: getting visible character range
  • Next by thread: Re: getting visible character range
  • Index(es):
    • Date
    • Thread