How to have unlimited tab stops in a NSTextView with disabled text wrap
There are several places on the net ( including stackoverflow ) pointing out how to disable text wrapping on a NSTextView object. The method works but there is a problem with the tab stops. It seems that the default is 12 tab stops, using more than 12 will start wrapp开发者_如何学Going. The obvious solution would be to change the default NSParagraphStyle so that it has more tab stops, but I dont think this is the proper way to do it. Ideally I would like to have "infinity" amount of tab stops, as for example xcode has.
Is there any straight forward way to achieve this?
This code will create a new paragraph style with 1/2 inch tab intervals and set it as both the default and current paragraph style on the variable textView.
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
[style setDefaultTabInterval:36.];
[style setTabStops:[NSArray array]];
[textView setDefaultParagraphStyle:style];
[textView setTypingAttributes:[NSDictionary dictionaryWithObject:style forKey:NSParagraphStyleAttributeName]];
[style release];
精彩评论