Layout manager's -rectArrayForCharacterRange:::: returns zero rectangles??
Layout manager's -rectArrayForCharacterRange:::: returns zero rectangles??
- Subject: Layout manager's -rectArrayForCharacterRange:::: returns zero rectangles??
- From: John Stiles <email@hidden>
- Date: Mon, 25 Feb 2008 10:52:14 -0800
I'm trying to write some code which figures out where the insertion
point is located, every time the selection changes. (Imagine a text
editor which has a "current line number" indicator at the bottom of the
screen that stays updated as the user types.)
To do this, in my text view's delegate, I have implemented the delegate
method -textViewDidChangeSelection:. From there I call -selectedRange
and then ask the layout manager for the rectangles via:
NSRectArray rects = [[myTextView layoutManager]
rectArrayForCharacterRange:selection
withinSelectedCharacterRange:NSMakeRange(NSNotFound, 0)
inTextContainer:[myTextView textContainer]
rectCount:&rectCount];
Normally, this works perfectly.
However, if I go to the very end of the document and start making
insertions or deletions, I don't get a rectangle back—"rectCount" is
zero. I've checked [[[TextView() textStorage] string] length] and
compared it against the selection, so I'm pretty confident that I'm not
querying past the end of the text, which in the past is the only time
I've seen behavior like this up until now.
Any ideas as to what's wrong? This seems pretty straightforward to me so
I'm not sure what I'm missing.
_______________________________________________
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