Re: Creating a single Tab Stop in an NSTextView
Re: Creating a single Tab Stop in an NSTextView
- Subject: Re: Creating a single Tab Stop in an NSTextView
- From: Patrick Meirmans <email@hidden>
- Date: Fri, 20 Jan 2006 18:29:47 -0500
The following code works for me to insert a number tabstops, though I
think it is more or less the same as what you do. I cut out some code
where I programmatically set the number of tabs and their spacing, so
there is the risk that I cut out a bit too much and the code will
generate some errors, but you will get the general idea:
int i;
int numStops = 100;
int tabInterval = 80.0;
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 (i = 1; i <= numStops; i++) {
tabStop = [[NSTextTab alloc] initWithType:NSLeftTabStopType
location: tabInterval * i];
[paraStyle addTabStop:tabStop];
[tabStop release];
}
[attrs setObject:paraStyle forKey:NSParagraphStyleAttributeName];
[paraStyle release];
[[dataTextView textStorage] addAttributes:attrs
range:NSMakeRange(0, [[[myTextView textStorage] string] length])];
[attrs release];
On 17 Jan, 2006, at 11:46, Ian was here wrote:
I'm trying to reset the position of the first tab stop
within my text view. I would like it to be at position
48. For some reason the following code doesn't seem to
do the trick. Has anyone else done something similar
to this?
NSMutableParagraphStyle *theParagraphStyle =
[[NSMutableParagraphStyle alloc] init];
NSTextTab *textTab = [[NSTextTab alloc]
initWithType:NSLeftTabStopType location:48.0];
NSArray *tabStop = [[NSArray alloc]
initWithObjects:textTab, nil];
[theParagraphStyle setTabStops:tabStop];
[textView setDefaultParagraphStyle:theParagraphStyle];
[tabStop release];
[textTab release];
[theParagraphStyle release];
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
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