Mac Developer Library

Developer

AppKit Framework Reference NSTabViewItem Class Reference

Options
Deployment Target:

On This Page
Language:

NSTabViewItem

An NSTabViewItem is a convenient way for presenting information in multiple pages. A tab view is usually distinguished by a row of tabs that give the visual appearance of folder tabs. When the user clicks a tab, the tab view displays a view page provided by your application. A tab view keeps a zero-based array of NSTabViewItems, one for each tab in the view.

Inheritance


Conforms To


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.
  • Performs default initialization for the receiver.

    Declaration

    Swift

    init(identifier identifier: AnyObject)

    Objective-C

    - (instancetype)initWithIdentifier:(id)identifier

    Discussion

    Sets the receiver’s identifier object to identifier, if it is not nil. Use this method when creating tab view items programmatically.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Draws the receiver’s label in tabRect, which is the area between the curved end caps.

    Declaration

    Swift

    func drawLabel(_ shouldTruncateLabel: Bool, inRect labelRect: NSRect)

    Objective-C

    - (void)drawLabel:(BOOL)shouldTruncateLabel inRect:(NSRect)labelRect

    Discussion

    If shouldTruncateLabel is NOfalse, draws the full label in the rectangle specified by tabRect. If shouldTruncateLabel is YEStrue, draws the truncated label. You can override this method to perform customized label drawing. For example, you might want to add an icon to each tab in the view.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the label text for the receiver.

    Declaration

    Swift

    var label: String

    Objective-C

    @property(copy) NSString *label

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setLabel:

  • Sets the label text for the receiver to label.

    Declaration

    Swift

    var label: String

    Objective-C

    @property(copy) NSString *label

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – label

  • Calculates the size of the receiver’s label.

    Declaration

    Swift

    func sizeOfLabel(_ computeMin: Bool) -> NSSize

    Objective-C

    - (NSSize)sizeOfLabel:(BOOL)computeMin

    Discussion

    If shouldTruncateLabel is NOfalse, returns the size of the receiver’s full label. If shouldTruncateLabel is YEStrue, returns the truncated size. If your application does anything to change the size of tab labels, such as overriding the drawLabel:inRect: method to add an icon to each tab, you should override sizeOfLabel: too so the NSTabView knows the correct size for the tab label.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the current display state of the tab associated with the receiver.

    Declaration

    Swift

    var tabState: NSTabState { get }

    Objective-C

    @property(readonly) NSTabState tabState

    Discussion

    The possible values are NSSelectedTab, NSBackgroundTab, or NSPressedTab. Your application does not directly set the tab state.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s optional identifier object.

    Declaration

    Swift

    var identifier: AnyObject

    Objective-C

    @property(strong) id identifier

    Discussion

    To customize how your application works with tabs, you can initialize each tab view item with an identifier object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the receiver’s optional identifier object to identifier.

    Declaration

    Swift

    var identifier: AnyObject

    Objective-C

    @property(strong) id identifier

    Discussion

    To customize how your application works with tabs, you can specify an identifier object for each tab view item.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the color for the receiver.

    Declaration

    Swift

    @NSCopying var color: NSColor

    Objective-C

    @property(copy) NSColor *color

    Discussion

    The color is specified by the current theme.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setColor:

  • Deprecated. NSTabViewItems use a color supplied by the current theme.

    Declaration

    Swift

    @NSCopying var color: NSColor

    Objective-C

    @property(copy) NSColor *color

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – color

  • Returns the view associated with the receiver.

    Declaration

    Swift

    var view: NSView?

    Objective-C

    @property(strong) NSView *view

    Discussion

    This is the view displayed when a user clicks the tab.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – setView:

  • Sets the view associated with the receiver to view.

    Declaration

    Swift

    var view: NSView?

    Objective-C

    @property(strong) NSView *view

    Discussion

    This is the view displayed when a user clicks the tab. When you set a new view, the old view is released.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    – view

  • Returns the initial first responder for the view associated with the receiver.

    Declaration

    Swift

    unowned(unsafe) var initialFirstResponder: NSView?

    Objective-C

    @property(assign) NSView *initialFirstResponder

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the initial first responder for the view associated with the receiver (the view that is displayed when a user clicks on the tab) to view.

    Declaration

    Swift

    unowned(unsafe) var initialFirstResponder: NSView?

    Objective-C

    @property(assign) NSView *initialFirstResponder

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the parent tab view for the receiver.

    Declaration

    Swift

    var tabView: NSTabView? { get }

    Objective-C

    @property(readonly) NSTabView *tabView

    Discussion

    Note that this is the tab view itself, not the view displayed when a user clicks the tab.

    A tab view item normally learns about its parent tab view when it is inserted into the view’s array of items. The NSTabView methods addTabViewItem: and insertTabViewItem:atIndex: set the tab view for the added or inserted item.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the tooltip displayed for the tab view item

    Declaration

    Swift

    var toolTip: String?

    Objective-C

    @property(copy) NSString *toolTip

    Return Value

    A string representing the tooltip to be displayed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

    See Also

    – setToolTip:

  • Sets the tooltip displayed for the tab view item.

    Declaration

    Swift

    var toolTip: String?

    Objective-C

    @property(copy) NSString *toolTip

    Parameters

    toolTip

    A string representing the tooltip to be displayed.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.6 and later.

    See Also

    – toolTip

Data Types

  • These constants describe the current display state of a tab:

    Declaration

    Swift

    enum NSTabState : UInt { case SelectedTab case BackgroundTab case PressedTab }

    Objective-C

    typedef enum _NSTabState { NSSelectedTab = 0, NSBackgroundTab = 1, NSPressedTab = 2 } NSTabState;

    Constants

    • BackgroundTab

      NSBackgroundTab

      A tab that’s not being displayed.

      Available in OS X v10.0 and later.

    • PressedTab

      NSPressedTab

      A tab that the user is in the process of clicking. That is, the user has pressed the mouse button while the cursor is over the tab but has not released the mouse button.

      Available in OS X v10.0 and later.

    • SelectedTab

      NSSelectedTab

      The tab that’s being displayed.

      Available in OS X v10.0 and later.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.