Mac Developer Library

Developer

AppKit Framework Reference NSTextTab Class Reference

Options
Deployment Target:

On This Page
Language:

NSTextTab

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.

  • The receiver’s ruler location relative to the back margin. (read-only)

    Declaration

    Swift

    var location: CGFloat { get }

    Objective-C

    @property(readonly) CGFloat location

    Availability

    Available in OS X v10.0 and later.

  • tabStopType tabStopType (OS X v10.11) Property

    The receiver’s tab stop type. (read-only)

    Declaration

    Swift

    var tabStopType: NSTextTabType { get }

    Objective-C

    @property(readonly) NSTextTabType tabStopType

    Discussion

    Possible values are listed in NSTextTabType.

    Availability

    Available in OS X v10.0 and later.

    Deprecated in OS X v10.11.

  • The text alignment of the receiver. (read-only)

    Declaration

    Swift

    var alignment: NSTextAlignment { get }

    Objective-C

    @property(readonly) NSTextAlignment alignment

    Availability

    Available in OS X v10.3 and later.

  • The dictionary of attributes associated with the receiver. (read-only)

    Declaration

    Swift

    var options: [String : AnyObject] { get }

    Objective-C

    @property(readonly) NSDictionary <NSString *,id> *options

    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.0 and later.