• 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
Setting Tab Stops (again)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Setting Tab Stops (again)


  • Subject: Setting Tab Stops (again)
  • From: Christian Mike <email@hidden>
  • Date: Tue, 31 Jul 2001 15:16:08 -0500

I am trying to set a different collection of tab stops in an NSTextView
besides the default set, which are 28 points apart. I am setting up a fixed
point font, and I want a tab stop every 4 columns (5, 9, 13, etc). My window
is fairly wide, so I am setting up 64 tabs stops. My code looks like:

NSMutableParagraphStyle *paragraphStyle;
float fCharacterWidth, fTabPosition;
long lIndex;
NSMutableArray *tabArray = [NSMutableArray
arrayWithCapacity:64];
NSFont *textFont = [NSFont
userFixedPitchFontOfSize:14.0];

[myTextView setFont:textFont];
fCharacterWidth = [textFont widthOfString:@"X"];
fTabPosition = 5.0 * fCharacterWidth;
[tabArray addObject:[[NSTextTab alloc]
initWithType:NSLeftTabStopType location:fTabPosition]];
for(lIndex=1; lIndex<64; ++lIndex)
{
fTabPosition += 4.0 * fCharacterWidth;
[tabArray addObject:[[NSTextTab alloc]
initWithType:NSLeftTabStopType location:fTabPosition]];
}
paragraphStyle = [[NSParagraphStyle defaultParagraphStyle]
mutableCopy];
[paragraphStyle setTabStops:tabArray];
myTextStorage = [myTextView textStorage];
[myTextStorage
setAttributes:[NSDictionary
dictionaryWithObject:paragraphStyle forKey:NSParagraphStyleAttributeName]
range:NSMakeRange(0,[myTextStorage length])];


I am assuming this fails because to start with, this NSTextView has no
contents, so it is setting the attributes of nothing.

How do I set the default attributes of my NSTextView so that my tab stop
array sticks, even if the contents of the view are deleted and replaced with
some other text contents.

Thanks.

Michael Christian
Thomson multimedia Inc.


  • Prev by Date: Re: Learning question about NSTableView and NSStrings
  • Next by Date: Re: Newbye with .. a button :-))
  • Previous by thread: Re: Using NSDrawer's
  • Next by thread: Text Sizing
  • Index(es):
    • Date
    • Thread