NSTabViewItem Class Reference

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

Overview

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.

Tasks

Creating a Tab View Item

Working with Labels

Checking the Tab Display State

Assigning an Identifier Object

Setting the Color

Assigning a View

Setting the Initial First Responder

Accessing the Parent Tab View

Getting and Setting Tooltips

Instance Methods

color

Returns the color for the receiver.

- (NSColor *)color
Discussion

The color is specified by the current theme.

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

drawLabel:inRect:

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

- (void)drawLabel:(BOOL)shouldTruncateLabel inRect:(NSRect)tabRect
Discussion

If shouldTruncateLabel is NO, draws the full label in the rectangle specified by tabRect. If shouldTruncateLabel is YES, 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.

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

identifier

Returns the receiver’s optional identifier object.

- (id)identifier
Discussion

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

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

initialFirstResponder

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

- (id)initialFirstResponder
Availability
  • Available in OS X v10.0 and later.
Declared In
NSTabViewItem.h

initWithIdentifier:

Performs default initialization for the receiver.

- (id)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.

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

label

Returns the label text for the receiver.

- (NSString *)label
Availability
  • Available in OS X v10.0 and later.
Declared In
NSTabViewItem.h

setColor:

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

- (void)setColor:(NSColor *)color
Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSTabViewItem.h

setIdentifier:

Sets the receiver’s optional identifier object to identifier.

- (void)setIdentifier:(id)identifier
Discussion

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

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

setInitialFirstResponder:

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.

- (void)setInitialFirstResponder:(NSView *)view
Availability
  • Available in OS X v10.0 and later.
Related Sample Code
Declared In
NSTabViewItem.h

setLabel:

Sets the label text for the receiver to label.

- (void)setLabel:(NSString *)label
Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSTabViewItem.h

setToolTip:

Sets the tooltip displayed for the tab view item.

- (void)setToolTip:(NSString *)toolTip
Parameters
toolTip

A string representing the tooltip to be displayed.

Availability
  • Available in OS X v10.6 and later.
See Also
Declared In
NSTabViewItem.h

setView:

Sets the view associated with the receiver to view.

- (void)setView:(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.

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

sizeOfLabel:

Calculates the size of the receiver’s label.

- (NSSize)sizeOfLabel:(BOOL)shouldTruncateLabel
Discussion

If shouldTruncateLabel is NO, returns the size of the receiver’s full label. If shouldTruncateLabel is YES, 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.

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

tabState

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

- (NSTabState)tabState
Discussion

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

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

tabView

Returns the parent tab view for the receiver.

- (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.

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

toolTip

Returns the tooltip displayed for the tab view item

- (NSString *)toolTip
Return Value

A string representing the tooltip to be displayed.

Availability
  • Available in OS X v10.6 and later.
Declared In
NSTabViewItem.h

view

Returns the view associated with the receiver.

- (id)view
Discussion

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

Availability
  • Available in OS X v10.0 and later.
See Also
Declared In
NSTabViewItem.h

Constants

NSTabState

These constants describe the current display state of a tab:

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

A tab that’s not being displayed.

Available in OS X v10.0 and later.

Declared in NSTabViewItem.h.

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.

Declared in NSTabViewItem.h.

NSSelectedTab

The tab that’s being displayed.

Available in OS X v10.0 and later.

Declared in NSTabViewItem.h.

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