• 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
Re: Changing the line height of an NSTextField?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Changing the line height of an NSTextField?


  • Subject: Re: Changing the line height of an NSTextField?
  • From: Nicholas J Humfrey <email@hidden>
  • Date: Wed, 26 Mar 2008 22:48:19 +0000


On 26 Mar 2008, at 22:17, Douglas Davidson wrote:

On Mar 26, 2008, at 3:10 PM, Nicholas J Humfrey wrote:

In the end I subclased the NSTextField class and overrid the drawRect function. I then split the string up into its lines and drew them myself using drawRect. This is some of the first Cocoa code I have written, so please don't hurt me if what I am doing is crazy!

Well, what you're doing is using only explicit line breaks, rather than allowing wrapping, and you're taking into account only \n as a line separator, rather than handling all of the line and paragraph break characters. What you're doing will work, more or less, but it's not sufficiently general to be a real solution.

Yes. It certainly isn't a real/generic solution. In this case I actually wanted the lines to clip, rather than wrap if the user hadn't explicitly sorted them out previously in the application.



I missed the initial question, but in general line heights are controlled by an NSParagraphStyle, which is used as the value of the NSParagraphStyleAttributeName attribute. This is the same object that controls most paragraph-level styling, including line breaking, alignment, etc.


Ah, cool, thanks. Not sure why I didn't find that with Google!


nick.

_______________________________________________

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


References: 
 >Changing the line height of an NSTextField? (From: Nicholas J Humfrey <email@hidden>)
 >Re: Changing the line height of an NSTextField? (From: John Stiles <email@hidden>)
 >Re: Changing the line height of an NSTextField? (From: Nicholas J Humfrey <email@hidden>)
 >Re: Changing the line height of an NSTextField? (From: Douglas Davidson <email@hidden>)

  • Prev by Date: NSPersistentDocument Revert Question
  • Next by Date: Re: Leopard on PPC
  • Previous by thread: Re: Changing the line height of an NSTextField?
  • Next by thread: Basic question about NSComboBox
  • Index(es):
    • Date
    • Thread