finding text to be drawn in NSTextView drawRect
finding text to be drawn in NSTextView drawRect
- Subject: finding text to be drawn in NSTextView drawRect
- From: Scott Royston <email@hidden>
- Date: Thu, 23 May 2002 00:31:41 -0500
I'm currently trying to figure out the range of text that needs to be
redrawn (in drawRect) in an NSTextView.
It's turning out to be a pain, and I'm hoping I'm doing it the hard
way. Here's what I currently have hacked together:
startPoint.x = rect.origin.x;
startPoint.y = rect.origin.y;
endPoint.x = rect.origin.x;// + rect.size.width -20;
endPoint.y = rect.origin.y + rect.size.height -20;
startPoint = [self convertPoint: startPoint toView: nil];
endPoint = [self convertPoint: endPoint toView: nil];
startPoint = [[self window] convertBaseToScreen: startPoint];
endPoint = [[self window] convertBaseToScreen: endPoint];
area.location = [self characterIndexForPoint: startPoint];
area.length = [self characterIndexForPoint: endPoint] -
area.location;
the only function I could find to get me there was
characterIndexForPoint (in screen coord, no less, ugh). problem is
using a point is very hit or miss. knowing that the text is left to
right helps a little, because I have a better chance of 'hitting' a
character down the left side of the page, but it still doesn't work very
well. before I go further down this path I was hoping somebody had an
easier way.
thanks
_______________________________________________
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.