Mac Developer Library

Developer

AppKit Framework Reference NSTextTab Class Reference

Options
Deployment Target:

On This Page
Language:

NSTextTab

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

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.

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

    Declaration

    Swift

    init(type type: NSTextTabType, location loc: CGFloat)

    Objective-C

    - (instancetype)initWithType:(NSTextTabType)type location:(CGFloat)loc

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

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

    Declaration

    Swift

    init(textAlignment alignment: NSTextAlignment, location loc: CGFloat, options options: [NSObject : AnyObject]?)

    Objective-C

    - (instancetype)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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

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

    Declaration

    Swift

    var location: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat location

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s tab stop type.

    Declaration

    Swift

    var tabStopType: NSTextTabType { get }

    Objective-C

    @property(readonly) NSTextTabType tabStopType

    Return Value

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

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the text alignment of the receiver.

    Declaration

    Swift

    var alignment: NSTextAlignment { get }

    Objective-C

    @property(readonly) NSTextAlignment alignment

    Return Value

    The text alignment of the receiver as an NSTextAlignment constant

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the dictionary of attributes associated with the receiver.

    Declaration

    Swift

    var options: [NSObject : AnyObject]? { get }

    Objective-C

    @property(readonly, copy) NSDictionary *options

    Return Value

    The dictionary of attributes associated with the receiver.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

Data Types

  • These constants describe the various type of tab stop.

    Declaration

    Swift

    enum NSTextTabType : UInt { case LeftTabStopType case RightTabStopType case CenterTabStopType case DecimalTabStopType }

    Objective-C

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

    Constants

    • LeftTabStopType

      NSLeftTabStopType

      A left-aligned tab stop.

      Available in OS X v10.0 and later.

    • RightTabStopType

      NSRightTabStopType

      A right-aligned tab stop.

      Available in OS X v10.0 and later.

    • CenterTabStopType

      NSCenterTabStopType

      A center-aligned tab stop.

      Available in OS X v10.0 and later.

    • DecimalTabStopType

      NSDecimalTabStopType

      Aligns columns of numbers by the decimal point.

      Available in OS X v10.0 and later.

    Discussion

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

    Alignment

    Tab Stop Type

    NSLeftTextAlignment

    NSLeftTabStopType

    NSRightTextAlignment

    NSRightTabStopType

    NSCenterTextAlignment

    NSCenterTabStopType

    NSJustifiedTextAlignment

    NSLeftTabStopType

    NSNaturalTextAlignment

    NSLeftTabStopType or NSRightTabStopType, depending on the user setting

    NSRightTextAlignment with terminator

    NSDecimalTabStopType

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • This constant specifies the terminating character for a tab column.

    Declaration

    Swift

    let NSTabColumnTerminatorsAttributeName: String

    Objective-C

    NSString *NSTabColumnTerminatorsAttributeName;

    Constants

    • NSTabColumnTerminatorsAttributeName

      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.