• 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: Possible to set tab stops in an NSTextView?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible to set tab stops in an NSTextView?


  • Subject: Re: Possible to set tab stops in an NSTextView?
  • From: Ashley Clark <email@hidden>
  • Date: Sun, 21 Jun 2009 11:53:50 -0500

On Jun 21, 2009, at 10:44 AM, Ken Tozier wrote:

Hi

I'm working with an NSText view and want to display tab delimited strings in a table format. I don't need a full NSTable, just the ability to break up the text into columns using tab stops. Is there any built-in way to do this? Something like setTabStops?

I looked in NSTextView, NSText, NSTextContainer and NSAttributedString but didn't see anything.

You need to create an NSMutableParagraphStyle, set you tab stops on it with setTabStops: and then add it as an attribute to your attributed string in your text view.


Code written in Mail, YMMV:

NSArray *tabStops = /* your array */

NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setTabStops:tabStops];


[[textView textStorage] addAttribute:NSParagraphStyleAttributeName value:style range: /* effective range */ ];

/* if you're doing this in response to a user action you should also update the typing attributes */
NSMutableDictionary *typingAttributes = [[textView typingAttributes] mutableCopy];
[typingAttributes setObject:style forKey:NSParagraphStyleAttributeName];
[textView setTypingAttributes:typingAttributes];


[typingAttributes release];
[style release];



Ashley
_______________________________________________

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


  • Follow-Ups:
    • Re: Possible to set tab stops in an NSTextView?
      • From: Ken Tozier <email@hidden>
References: 
 >Possible to set tab stops in an NSTextView? (From: Ken Tozier <email@hidden>)

  • Prev by Date: Re: Cocoa and Computational Expense
  • Next by Date: Re: Core Data "Uniqueing" not happening as expected
  • Previous by thread: Re: Possible to set tab stops in an NSTextView?
  • Next by thread: Re: Possible to set tab stops in an NSTextView?
  • Index(es):
    • Date
    • Thread