• 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
Re: Creating a single Tab Stop in an NSTextView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Follow-Ups:
    • Re: Creating a single Tab Stop in an NSTextView
      • From: Ian was here <email@hidden>
References: 
 >Creating a single Tab Stop in an NSTextView (From: Ian was here <email@hidden>)

  • Prev by Date: Re: Screensaver
  • Next by Date: Resolving aliases with a time-out
  • Previous by thread: Creating a single Tab Stop in an NSTextView
  • Next by thread: Re: Creating a single Tab Stop in an NSTextView
  • Index(es):
    • Date
    • Thread