Making NSTextView draw like NSString's -drawInRect:withAttributes:?
Making NSTextView draw like NSString's -drawInRect:withAttributes:?
- Subject: Making NSTextView draw like NSString's -drawInRect:withAttributes:?
- From: Keith Blount <email@hidden>
- Date: Thu, 16 Feb 2006 09:55:41 -0800 (PST)
This is something that has been asked numerous times
on this list and elsewhere, but I have yet to find a
workable solution.
I have a custom view which draws various boxes of text
using NSString's -drawInRect:withAttributes:. I am
currently improving this view so that each box is
editable. This part isn't too difficult - I just add
an NSTextView as a subview at the location of the
edited box when a box is double-clicked.
My problem is that no matter what I do, I cannot get
the text as it is drawn in the text view to match the
text as it is drawn by NSString's methods. In the text
view, each line of text is about 1 pixel smaller than
when it is drawn by NSString. (I have called
-setLineFragmentPadding: on the text container and set
it to 0.0 so that it matches horizontally). I have
tried everything I can think of, including using
paragraph attributes such as setMinimumLineSpacing:
(though I want the text view as plain text), and
setting the text view as the field editor using
-setFieldEditor:YES.
Is there any way to make an NSTextView's drawing match
the -drawInRect... methods of NSString or
NSAttributedString?
(My other option is to use an NSTextView to draw the
text in the boxes all the time - ie. by adding it as a
subview, displaying it and removing it for each box
during drawing. However, this has drawbacks, too -
most notably that I cannot create a drag image if I do
this by locking focus on an image and calling my
-drawTextBoxInRect: method. So I would have to find a
different way of creating a drag image, and I fear
this solution is much heavier anyway.)
Many thanks in advance for any suggestions.
All the best,
Keith
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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