NSTextTab Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in OS X v10.0 and later.
Companion guide
Text System Overview
Declared in
NSParagraphStyle.h
Related sample code

Overview

An NSTextTab object represents a tab in an NSParagraphStyle object, storing an alignment type and location. NSTextTab objects are most frequently used with the Application Kit’s text system and with NSRulerView and NSRulerMarker objects. See the appropriate class specifications for more information on these uses.

The text system supports four alignment types: left, center, right, and decimal (based on the decimal separator character of the locale in effect). These alignment types are absolute, not based on the line sweep direction of text. For example, tabbed text is always positioned to the left of a right-aligned tab, whether the line sweep direction is left to right or right to left. A tab’s location, on the other hand, is relative to the back margin. A tab set at 1.5”, for example, is at 1.5” from the right in right to left text.

Adopted Protocols

NSCoding
NSCopying

Tasks

Creating an NSTextTab

Getting Tab Stop Information

Getting Text Tab Information

Instance Methods

alignment

Returns the text alignment of the receiver.

- (NSTextAlignment)alignment
Return Value

The text alignment of the receiver as an NSTextAlignment constant

Availability
  • Available in OS X v10.3 and later.
Declared In
NSParagraphStyle.h

initWithTextAlignment:location:options:

Initializes a text tab with the text alignment, location, and options.

- (id)initWithTextAlignment:(NSTextAlignment)alignment location:(CGFloat)loc options:(NSDictionary *)options
Discussion

The text alignment is used to determine the position of text inside the tab column. See NSTextTabType for a mapping between alignments and tab stop types

Availability
  • Available in OS X v10.3 and later.
Declared In
NSParagraphStyle.h

initWithType:location:

Initializes a newly allocated NSTextTab with an alignment of type at location on the paragraph.

- (id)initWithType:(NSTextTabType)type location:(CGFloat)location
Discussion

The location is relative to the back margin, based on the line sweep direction of the paragraph. type can be any of the values described in NSTextTabType.

Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSParagraphStyle.h

location

Returns the receiver’s ruler location relative to the back margin.

- (CGFloat)location
Return Value

The receiver’s ruler location relative to the back margin.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSParagraphStyle.h

options

Returns the dictionary of attributes associated with the receiver.

- (NSDictionary *)options
Return Value

The dictionary of attributes associated with the receiver.

Availability
  • Available in OS X v10.3 and later.
Declared In
NSParagraphStyle.h

tabStopType

Returns the receiver’s tab stop type.

- (NSTextTabType)tabStopType
Return Value

The receiver’s tab stop type. Possible values are listed in NSTextTabType.

Availability
  • Available in OS X v10.0 and later.
Declared In
NSParagraphStyle.h

Constants

NSTextTabType

These constants describe the various type of tab stop.

typedef enum _NSTextTabType {
   NSLeftTabStopType = 0,
   NSRightTabStopType,
   NSCenterTabStopType,
   NSDecimalTabStopType
} NSTextTabType;
Constants
NSLeftTabStopType

A left-aligned tab stop.

Available in OS X v10.0 and later.

Declared in NSParagraphStyle.h.

NSRightTabStopType

A right-aligned tab stop.

Available in OS X v10.0 and later.

Declared in NSParagraphStyle.h.

NSCenterTabStopType

A center-aligned tab stop.

Available in OS X v10.0 and later.

Declared in NSParagraphStyle.h.

NSDecimalTabStopType

Aligns columns of numbers by the decimal point.

Available in OS X v10.0 and later.

Declared in NSParagraphStyle.h.

Discussion

The following mappings define the conversions between text alignment in NSTextTab and tab stop types defined by NSTextTab:

Availability
  • Available in OS X v10.0 and later.
Declared In
NSParagraphStyle.h

Terminating character

This constant specifies the terminating character for a tab column.

NSString *NSTabColumnTerminatorsAttributeName;
Constants
NSTabColumnTerminatorsAttributeName

The value is an NSCharacterSet object.

The character set is used to determine the terminating character for a tab column. The tab and newline characters are implied even if they don’t exist in the character set. This attribute is optional.

Available in OS X v10.3 and later.

Declared in NSParagraphStyle.h.

Declared In
NSParagraphStyle.h