Re: Problems with NSTextField and attributed strings
Re: Problems with NSTextField and attributed strings
- Subject: Re: Problems with NSTextField and attributed strings
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 21 Jul 2004 17:12:32 -0700
Hello...
NSParagraphStyle also has the setTabStops: method, which should allow
you to replace the current tab stops with your own array of NSTextTab
instances, and which doesn't require removing the old tab stops at
all (at least according to the documentation).
NSTextTab *numberTab = [[NSTextTab alloc]
initWithType:NSRightTabStopType location:30.0];
NSTextTab *textTab = [[NSTextTab alloc]
initWithType:NSLeftTabStopType location:34.0];
[style setTabStops:[NSArray arrayWithObjects:numberTab, textTab, nil]];
[numberTab release];
[textTab release];
Hope that helps,
Louis
And finally, third: I discovered that doing the following:
NSMutableParagraphStyle * style = [[NSMutableParagraphStyle alloc] init];
appears to initialize the style as though I had used
[NSParagraphStyle defaultParagraphStyle] -- in particular, it was
loaded with tab stops set every 28.0 points apart. So, to set my
own specific tab stops, I go through this chunk of code:
NSLog(@"Removing %d tab stops", [[style tabStops] count]);
for (i = 0; i < [[style tabStops] count]; ++i)
{
[style removeTabStop: [[style tabStops] objectAtIndex: i]];
}
NSTextTab * numberTab = [[NSTextTab alloc] initWithType:
NSRightTabStopType location: 30.0];
[style addTabStop: numberTab];
[numberTab release];
NSTextTab * textTab = [[NSTextTab alloc] initWithType:
NSLeftTabStopType location: 34.0];
[style addTabStop: textTab];
[textTab release];
The log statement confirms the intent to remove 12 tab stops.
However, debugging output immediately following this code shows that
my two tab stops are followed by 6 other tab stops, starting at 56.0
points and every 56.0 points thereafter. Why? I even added this
line of code:
[style setDefaultTabInterval: -1.0]; // disable extra tabs?
Before manipulating the tab stops, and nothing changed.
-- Tim C.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.