Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: NSTextView and ruler tab settings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTextView and ruler tab settings



Thanks very much for the suggestion and the sample code. I'll plunge back into the problem over the next few days.

Boyd



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.


Take a look at NSMutableParagraphStyle.  That's where
you can set tab stops as well as indentation.

Scott


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: This email sent to email@hidden
References: 
 >NSTextView and ruler tab settings (From: Boyd Collier <email@hidden>)
 >Re: NSTextView and ruler tab settings (From: PGM <email@hidden>)



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

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.