• 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
finding text to be drawn in NSTextView drawRect
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: finding text to be drawn in NSTextView drawRect
      • From: Douglas Davidson <email@hidden>
    • Re: finding text to be drawn in NSTextView drawRect
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: Cycle Through Windows
  • Next by Date: Re: finding text to be drawn in NSTextView drawRect
  • Previous by thread: Re: Cycle Through Windows
  • Next by thread: Re: finding text to be drawn in NSTextView drawRect
  • Index(es):
    • Date
    • Thread