Re: NSTextView and ruler tab settings
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