NSTabView 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 | NSTabView.h |
Overview
An NSTabView object provides a convenient way to present information in multiple pages. The view contains a row of tabs that give the appearance of folder tabs, as shown in the following figure. The user selects the desired page by clicking the appropriate tab or using the arrow keys to move between pages. Each page displays a view hierarchy provided by your application.

Tasks
Adding and Removing Tabs
Accessing Tabs
-
– indexOfTabViewItem: -
– indexOfTabViewItemWithIdentifier: -
– numberOfTabViewItems -
– tabViewItemAtIndex: -
– tabViewItems
Selecting a Tab
-
– selectFirstTabViewItem: -
– selectLastTabViewItem: -
– selectNextTabViewItem: -
– selectPreviousTabViewItem: -
– selectTabViewItem: -
– selectTabViewItemAtIndex: -
– selectTabViewItemWithIdentifier: -
– selectedTabViewItem -
– takeSelectedTabViewItemFromSender:
Modifying the Font
Modifying the Tab Type
Modifying Controls Tint
Manipulating the Background
Determining the Size
Truncating Tab Labels
Assigning a Delegate
Event Handling
Instance Methods
addTabViewItem:
Adds the tab item specified by tabViewItem.
Parameters
- tabViewItem
The tab view item to be added.
Discussion
The item is added at the end of the array of tab items, so the new tab appears on the right side of the view. If the delegate supports it, invokes the delegate’s tabViewDidChangeNumberOfTabViewItems: method.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hallowsTruncatedLabels
Returns whether if the receiver allows truncating for labels that don’t fit on a tab.
Return Value
YES if the receiver allows truncating for labels that don’t fit on a tab, otherwise NO.
Discussion
The default is NO.
When truncating is allowed, the tab view inserts an ellipsis, if necessary, to fit a label in the tab.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hcontentRect
Returns the rectangle describing the content area of the receiver.
Return Value
Returns the rectangle describing the content area of the receiver.
Discussion
This area does not include the space required for the receiver’s tabs or borders (if any).
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hcontrolSize
Returns the size of the receiver.
Return Value
Valid return values are described inControl Sizes in NSCell Class Reference.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hcontrolTint
Returns the receiver’s control tint.
Return Value
The tab view’s control tint. See NSControlTint for the supported values.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hdelegate
Returns the receiver’s delegate.
Return Value
The object’s delegate.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hdrawsBackground
Returns whether if the receiver draws a background color when the tab view type is NSNoTabsNoBorder.
Return Value
YES if the receiver draws a background color when the tab view type is NSNoTabsNoBorder, otherwise NO.
Discussion
If the receiver uses bezeled edges or a line border, the appropriate background color for that border is used.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hfont
Returns the font for tab label text.
Return Value
Returns the tab view label font.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hindexOfTabViewItem:
Returns the index of the specified item in the tab view.
Parameters
- tabViewItem
The tab view item.
Return Value
The zero-based index of tabViewItem, or [NSNotFound] if the item is not found.
Discussion
The returned index is zero-based.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hindexOfTabViewItemWithIdentifier:
Returns the index of the item that matches the specified identifier. identifier, or NSNotFound if the item is not found.
Parameters
- identifier
The identifier of a tab view item.
Return Value
The zero-based index of the tab view item corresponding to identifier, or [NSNotFound] if the item is not found.
Discussion
The returned index is zero-based.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hinsertTabViewItem:atIndex:
Inserts tabViewItem into the receiver’s array of tab view items at index.
Parameters
- tabViewItem
The tab view item to be added.
- index
The index at which to insert the tab view item. The index parameter is zero-based.
Discussion
If there is a delegate and the delegate supports it, sends the delegate the tabViewDidChangeNumberOfTabViewItems: message.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hminimumSize
Returns the minimum size necessary for the receiver to display tabs in a useful way.
Return Value
The minimum size necessary for the receiver to display tabs in a useful way.
Discussion
You can use the value returned by this method to limit how much a user can resize a tab view.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hnumberOfTabViewItems
Returns the number of items in the receiver’s array of tab view items.
Return Value
The number of items in the tab view.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hremoveTabViewItem:
Removes the item specified by tabViewItem from the receiver’s array of tab view items.
Parameters
- tabViewItem
The tab view item to be removed.
Discussion
If there is a delegate and the delegate supports it, sends the delegate the tabViewDidChangeNumberOfTabViewItems: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hselectedTabViewItem
Returns the tab view item for the currently selected tab
Return Value
The currently selected tab view item, or nil if no item is selected.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hselectFirstTabViewItem:
This action method selects the first tab view item.
Parameters
- sender
Typically the object that sent invoked the message.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hselectLastTabViewItem:
This action method selects the last tab view item.
Parameters
- sender
Typically the object that sent invoked the message.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hselectNextTabViewItem:
This action method selects the next tab view item in the sequence.
Parameters
- sender
Typically the object that sent invoked the message.
Discussion
If the currently visible item is the last item in the sequence, this method does nothing, and the last page remains displayed.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hselectPreviousTabViewItem:
This action method selects the previous tab view item in the sequence.
Parameters
- sender
Typically the object that sent invoked the message.
Discussion
If the currently visible item is the first item in the sequence, this method does nothing, and the first page remains displayed.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hselectTabViewItem:
Selects the specified tab view item.
Parameters
- tabViewItem
The tab item to select.
Discussion
If there is a delegate and the delegate supports it, sends the delegate the tabView:shouldSelectTabViewItem: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hselectTabViewItemAtIndex:
Selects the tab view item specified by index.
Parameters
- index
The index of the tab item to selected.
Discussion
The index parameter is base 0. If there is a delegate and the delegate supports it, sends the delegate the tabView:shouldSelectTabViewItem: message.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hselectTabViewItemWithIdentifier:
Selects the tab view item specified by identifier.
Parameters
- identifier
The identifier of the tab item to select.
Availability
- Available in OS X v10.0 and later.
See Also
-
– setIdentifier:(NSTabViewItem) -
– identifier(NSTabViewItem) -
– selectTabViewItemAtIndex: -
– selectedTabViewItem
Declared In
NSTabView.hsetAllowsTruncatedLabels:
Sets whether the receiver allows truncating for names that don’t fit on a tab.
Parameters
- allowTruncatedLabels
YESif the receiver allows truncating for labels that don’t fit on a tab, otherwiseNO.
Discussion
The default is NO.
When truncating is allowed, the tab view inserts an ellipsis, if necessary, to fit a label in the tab.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hsetControlSize:
Sets the size of the receiver to controlSize.
Parameters
- controlSize
The size of the receiver. Valid values are described in
Control Sizesin NSCell Class Reference
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hsetControlTint:
Sets the receiver’s control tint to controlTint.
Parameters
- controlTint
The tab view’s control tint. See
NSControlTintfor the supported values.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hsetDelegate:
Sets the receiver’s delegate.
Parameters
- anObject
The delegate object. It must conform to the
NSTabViewDelegateprotocol.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hsetDrawsBackground:
Sets whether a background is drawn when the view type is NSNoTabsNoBorder to flag.
Parameters
- flag
YESif the background should be drawn, otherwiseNO.
Discussion
If the receiver has a bezeled border or a line border, the appropriate background for that border is used.
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.hsetFont:
Sets the font for tab label text to font.
Parameters
- font
The font to use as the tab view label font.
Discussion
Tab height is adjusted automatically to accommodate a new font size. If the view allows truncating, tab labels are truncated as needed.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hsetTabViewType:
Sets the tab type to tabViewType.
Parameters
- tabViewType
The tab type to display the tabs. The supported values are listed in
NSTabViewType
Availability
- Available in OS X v10.0 and later.
See Also
Declared In
NSTabView.htabViewItemAtIndex:
Returns the tab view item at index in the tab view’s array of items.
Parameters
- index
The index at which to insert the tab view item. The index parameter is zero-based.
Return Value
The tab view item at the specified index.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.htabViewItemAtPoint:
Returns the tab view item at the specified point.
Parameters
- point
The hit point.
Return Value
The tab view item under the hit point, or nil if no tab view item is under that location.
Discussion
You can use this method to find a tab view item based on a user’s mouse click.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.htabViewItems
Returns the receiver’s array of tab view items.
Return Value
An array of tab view items.
Discussion
A tab view keeps an array containing one tab view item for each tab in the view.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.htabViewType
Returns the tab type for the receiver.
Return Value
The tab type to display the tabs. The supported values are listed in NSTabViewType
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.htakeSelectedTabViewItemFromSender:
Sets the selected tab view item to the selected item obtained from the sender.
Parameters
- sender
Typically the object that sent invoked the message.
Discussion
If sender responds to the indexOfSelectedItem method, this method invokes that method and selects the tab view item at the specified index.
Availability
- Available in OS X v10.0 and later.
Declared In
NSTabView.hConstants
NSTabViewType
These constants specify the tab view’s type as used by tabViewType and setTabViewType:.
enum {
NSTopTabsBezelBorder = 0,
NSLeftTabsBezelBorder = 1,
NSBottomTabsBezelBorder = 2,
NSRightTabsBezelBorder = 3,
NSNoTabsBezelBorder = 4,
NSNoTabsLineBorder = 5,
NSNoTabsNoBorder = 6
};
typedef NSUInteger NSTabViewType;
Constants
NSTopTabsBezelBorderThe view includes tabs on the top of the view and has a bezeled border (the default).
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSNoTabsBezelBorderThe view does not include tabs and has a bezeled border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSNoTabsLineBorderThe view does not include tabs and has a lined border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSNoTabsNoBorderThe view does not include tabs and has no border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSBottomTabsBezelBorderTabs are on the bottom of the view with a bezeled border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSLeftTabsBezelBorderTabs are on the left of the view with a bezeled border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.NSRightTabsBezelBorderTabs are on the right of the view with a bezeled border.
Available in OS X v10.0 and later.
Declared in
NSTabView.h.
NSAppKitVersionNumberWithDirectionalTabs
This constant specifies the minimum version of the Application Kit that supports directional tabs.
#define NSAppKitVersionNumberWithDirectionalTabs 631.0
Constants
NSAppKitVersionNumberWithDirectionalTabsThe specific version of the AppKit framework that introduced support for directional tab items. Developers should not need to use this constant unless they are writing applications for OS X v10.1 and earlier.
Available in OS X v10.2 and later.
Declared in
NSTabView.h.
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-06-23)