Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: line spacing differences between NSTextView and NSAttributedString




On Feb 28, 2006, at 1:06 PM, Chris Eplett wrote:

I've got an NSAttributedString that I'm drawing using the drawInRect method in my view. Now, the user can edit this string by double clicking it. When they do so, I stop drawing the text, then position and show an NSTextView that has been populated with the NSAttributedString using [[view textStorage] setAttributedString:str]. When they click elsewhere, the contents of the NSTextView are transferred back to my NSAttributedString, and I hide the NSTextView and start drawing the string again.

Functionally, this all works like a charm. There is a problem, however, in that the line spacing is not the same when the text view draws it versus when I draw it w/ drawInRect.

The drawInRect method spaces the lines slightly further apart than NSTextView does, so the user sees an accordion effect as the text becomes editable.

I've tried explicitly setting the line spacing to 0 using NSParagraphStyle, to no avail.

Any thoughts on how I can get NSTextView and NSAttributedString's drawInRect methods to render the text with the same metrics?


Look in the archives for Aki's post on NSTypesetterBehavior.

Douglas Davidson

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >line spacing differences between NSTextView and NSAttributedString (From: Chris Eplett <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.