• 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: NSTextView and ruler tab settings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and ruler tab settings


  • Subject: Re: NSTextView and ruler tab settings
  • From: PGM <email@hidden>
  • Date: Wed, 29 Mar 2006 21:03:37 -0500

This is what I use to set 100 tabStops with interval 80. I had to weed out some additional code, so there is no guarantee that it works right away, but you will get the general idea

- (IBAction)formatTextView:(id)sender
{
    int cnt;
    int numStops = 100;
    int tabInterval = 80;
    NSTextTab *tabStop;

NSMutableDictionary *attrs = [[NSMutableDictionary alloc] init]; //attributes for attributed String of TextView

NSMutableParagraphStyle *paraStyle = [[NSMutableParagraphStyle alloc] init];

// This first clears all tab stops, then adds tab stops, at desired intervals...
[paraStyle setTabStops:[NSArray array]];
for (cnt = 1; cnt <= numStops; cnt++) {
tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType location: tabInterval * (cnt)];
[paraStyle addTabStop:tabStop];
[tabStop release];
}
[attrs setObject:paraStyle forKey:NSParagraphStyleAttributeName];
[paraStyle release];


[[myTextView textStorage] addAttributes:attrs range:NSMakeRange(0, [[[myTextView textStorage] string] length])];
[attrs release];
}



PGM.

On 27 Mar, 2006, at 22:37, Boyd Collier wrote:

I'd like to programmatically change all the tab settings in the ruler used by a particular instance of an NSTextView but haven't been able to find a simple way to do this. Any suggestions would be appreciated.

Boyd
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden


_______________________________________________ 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
  • Follow-Ups:
    • Re: NSTextView and ruler tab settings
      • From: Boyd Collier <email@hidden>
References: 
 >NSTextView and ruler tab settings (From: Boyd Collier <email@hidden>)

  • Prev by Date: Re: Round Rect
  • Next by Date: Re: Round Rect
  • Previous by thread: NSTextView and ruler tab settings
  • Next by thread: Re: NSTextView and ruler tab settings
  • Index(es):
    • Date
    • Thread