• 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: paragraph styles in NSTextView--help
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: paragraph styles in NSTextView--help


  • Subject: Re: paragraph styles in NSTextView--help
  • From: Martin Wierschin <email@hidden>
  • Date: Tue, 30 Dec 2008 13:44:31 -0800

I want to use different combinations of paragraph styles in nstextview .

for example : combination of linespacing, paragraphspacing, headindent and
tailindent . These all styles must be activated in a single operation ,such
as in a single buttonclick etc.

You'll want to work with the text storage of the text view and apply the paragraph styles to the text as necessary. Before you modify any attributes of the storage you'll want to call "shouldChangeTextInRange:replacementString:" and afterwards "didChangeText" if you want undo and editing restrictions handled for you. A single change would look something like this:


NSTextView* tv = GetMyTextView();
NSTextStorage* ts = [tv textStorage];
NSRange applyRange = NSMakeRange(0, [ts length]);

if( [tv shouldChangeTextInRange:applyRange replacementString:nil] ) {
// configure paragraph styles as desired and apply
NSMutableParagraphStyle* paraStyle = [[[NSParagraphStyle defaultParagraphStyle] mutableCopy] autorelease];
[paraStyle setHeadIndent:6];
[ts addAttribute:NSParagraphStyleAttributeName value:paraStyle range:applyRange];
[tv didChangeText];
}


You can apply as many distinct styles to different paragraphs as you see fit by changing the NSRange.

~Martin
_______________________________________________

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: 
 >paragraph styles in NSTextView--help (From: rethish <email@hidden>)

  • Prev by Date: Re: NSTableView headers
  • Next by Date: NSTreeController delete slowness...
  • Previous by thread: paragraph styles in NSTextView--help
  • Next by thread: NSColorWell shows no color
  • Index(es):
    • Date
    • Thread