Re: Using -scrollRectToVisible: in NSTextView
Re: Using -scrollRectToVisible: in NSTextView
- Subject: Re: Using -scrollRectToVisible: in NSTextView
- From: Douglas Davidson <email@hidden>
- Date: Tue, 6 Jul 2004 15:11:14 -0700
On Jul 6, 2004, at 3:02 PM, Jeremy Dronfield wrote:
I'm thinking that -glyphRangeForBoundingRect:inTextContainer: might
get me a range for recording, without there being any actual
selection, as in
NSRange visibleGlyphs = [[textView layoutManager]
glyphRangeForBoundingRect:[textView visibleRect]
inTextContainer:[textView textContainer]];
followed by -characterIndexForGlyphAtIndex: or
-characterRangeForGlyphRange:actualGlyphRange: I'd appreciate any tips
you have for how to get this right. Xcode does it, so there must be a
way.
Here are a couple of tips: the layout manager always works in
container coordinates, which are offset from view coordinates by the
view's textContainerOrigin. To convert a glyph range to a character
range, you can use characterRangeForGlyphRange:actualGlyphRange: and
just pass NULL for the second argument.
Douglas Davidson
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.