Next Page > Hide TOC

NSTabView Class Reference

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

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.


image: Art/tabview.gif

Tasks

Adding and Removing Tabs

Accessing Tabs

Selecting a Tab

Modifying the Font

Modifying the Tab Type

Modifying Controls Tint

Manipulating the Background

Determining the Size

Truncating Tab Labels

Assigning a Delegate

Event Handling

View’s Window

Selecting an item

Changing number of items in view

Instance Methods

addTabViewItem:

Adds the tab item specified by tabViewItem.

- (void)addTabViewItem:(NSTabViewItem *)tabViewItem

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
See Also
Declared In
NSTabView.h

allowsTruncatedLabels

Returns YES if the receiver allows truncating for labels that don’t fit on a tab.

- (BOOL)allowsTruncatedLabels

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
See Also
Declared In
NSTabView.h

contentRect

Returns the rectangle describing the content area of the receiver.

- (NSRect)contentRect

Discussion

This area does not include the space required for the receiver’s tabs or borders (if any).

Availability
Declared In
NSTabView.h

controlSize

Returns the size of the receiver.

- (NSControlSize)controlSize

Discussion

Valid return values are described in NSCell’s “Constants”.

Availability
See Also
Declared In
NSTabView.h

controlTint

Returns the receiver’s control tint.

- (NSControlTint)controlTint

Discussion

Valid return values are described in “Constants.”

Availability
See Also
Declared In
NSTabView.h

delegate

Returns the receiver’s delegate.

- (id)delegate

Availability
See Also
Declared In
NSTabView.h

drawsBackground

Returns YES if the receiver draws a background color when the tab view type is NSNoTabsNoBorder. If the receiver uses bezeled edges or a line border, the appropriate background color for that border is used.

- (BOOL)drawsBackground

Availability
See Also
Declared In
NSTabView.h

font

Returns the font for tab label text.

- (NSFont *)font

Availability
See Also
Declared In
NSTabView.h

indexOfTabViewItem:

Returns the index of the item that matches tabViewItem, or NSNotFound if the item is not found.

- (NSInteger)indexOfTabViewItem:(NSTabViewItem *)tabViewItem

Discussion

A tab view keeps an array containing one tab view item for each tab in the view—this array is the one that is searched. The returned index is base 0.

Availability
See Also
Declared In
NSTabView.h

indexOfTabViewItemWithIdentifier:

Returns the index of the item that matches identifier, or NSNotFound if the item is not found.

- (NSInteger)indexOfTabViewItemWithIdentifier:(id)identifier

Discussion

A tab view keeps an array containing one tab view item for each tab in the view—this array is the one that is searched. The returned index is base 0.

Availability
See Also
Declared In
NSTabView.h

insertTabViewItem:atIndex:

Inserts tabViewItem into the receiver’s array of tab view items at index.

- (void)insertTabViewItem:(NSTabViewItem *)tabViewItem atIndex:(NSInteger)index

Discussion

The index parameter is base 0. If there is a delegate and the delegate supports it, sends the delegate the tabViewDidChangeNumberOfTabViewItems: message.

Availability
See Also
Declared In
NSTabView.h

minimumSize

Returns the minimum size necessary for the receiver to display tabs in a useful way.

- (NSSize)minimumSize

Discussion

You can use the value returned by this method to limit how much a user can resize a tab view.

Availability
See Also
Declared In
NSTabView.h

numberOfTabViewItems

Returns the number of items in the receiver’s array of tab view items.

- (NSInteger)numberOfTabViewItems

Discussion

Because there is one item in the array for each tab in the view, this number is equivalent to the number of tabs in the view.

Availability
See Also
Declared In
NSTabView.h

removeTabViewItem:

Removes the item specified by tabViewItem from the receiver’s array of tab view items.

- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem

Discussion

If there is a delegate and the delegate supports it, sends the delegate the tabViewDidChangeNumberOfTabViewItems: message.

Availability
See Also
Declared In
NSTabView.h

selectedTabViewItem

Returns the tab view item for the currently selected tab, or nil if no item is selected.

- (NSTabViewItem *)selectedTabViewItem

Availability
See Also
Related Sample Code
Declared In
NSTabView.h

selectFirstTabViewItem:

This action method selects the first tab view item.

- (void)selectFirstTabViewItem:(id)sender

Availability
See Also
Declared In
NSTabView.h

selectLastTabViewItem:

This action method selects the last tab view item.

- (void)selectLastTabViewItem:(id)sender

Availability
See Also
Declared In
NSTabView.h

selectNextTabViewItem:

This action method selects the next tab view item in the sequence.

- (void)selectNextTabViewItem:(id)sender

Discussion

If the currently visible item is the last item in the sequence, this method does nothing, and the last page remains displayed.

Availability
See Also
Declared In
NSTabView.h

selectPreviousTabViewItem:

This action method selects the previous tab view item in the sequence.

- (void)selectPreviousTabViewItem:(id)sender

Discussion

If the currently visible item is the first item in the sequence, this method does nothing, and the first page remains displayed.

Availability
See Also
Declared In
NSTabView.h

selectTabViewItem:

Selects the tab view item specified by tabViewItem.

- (void)selectTabViewItem:(NSTabViewItem *)tabViewItem

Discussion

If there is a delegate and the delegate supports it, sends the delegate the tabView:shouldSelectTabViewItem: message.

Availability
See Also
Declared In
NSTabView.h

selectTabViewItemAtIndex:

Selects the tab view item specified by index.

- (void)selectTabViewItemAtIndex:(NSInteger)index

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
See Also
Declared In
NSTabView.h

selectTabViewItemWithIdentifier:

Selects the tab view item specified by identifier.

- (void)selectTabViewItemWithIdentifier:(id)identifier

Availability
See Also
Declared In
NSTabView.h

setAllowsTruncatedLabels:

Sets whether the receiver allows truncating for names that don’t fit on a tab to allowTruncatedLabels.

- (void)setAllowsTruncatedLabels:(BOOL)allowTruncatedLabels

Availability
See Also
Declared In
NSTabView.h

setControlSize:

Sets the size of the receiver to controlSize.

- (void)setControlSize:(NSControlSize)controlSize

Discussion

Valid values for controlSize are described in “Constants”.

Availability
See Also
Declared In
NSTabView.h

setControlTint:

Sets the receiver’s control tint to controlTint.

- (void)setControlTint:(NSControlTint)controlTint

Discussion

Valid values for controlTint are described in “Constants.”

Availability
See Also
Declared In
NSTabView.h

setDelegate:

Sets the receiver’s delegate to anObject.

- (void)setDelegate:(id)anObject

Availability
See Also
Declared In
NSTabView.h

setDrawsBackground:

Sets whether a background is drawn when the view type is NSNoTabsNoBorder to flag.

- (void)setDrawsBackground:(BOOL)flag

Discussion

If the receiver has a bezeled border or a line border, the appropriate background for that border is used.

Availability
See Also
Declared In
NSTabView.h

setFont:

Sets the font for tab label text to font.

- (void)setFont:(NSFont *)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
See Also
Declared In
NSTabView.h

setTabViewType:

Sets the tab type to tabViewType.

- (void)setTabViewType:(NSTabViewType)tabViewType

Discussion

The available types are described in “Constants.”

Availability
See Also
Declared In
NSTabView.h

tabViewItemAtIndex:

Returns the tab view item at index in the tab view’s array of items.

- (NSTabViewItem *)tabViewItemAtIndex:(NSInteger)index

Discussion

The index parameter is base 0.

Availability
See Also
Declared In
NSTabView.h

tabViewItemAtPoint:

Returns the tab view item identified by point.

- (NSTabViewItem *)tabViewItemAtPoint:(NSPoint)point

Discussion

You can use this method to find a tab view item based on a user’s mouse click.

Availability
Declared In
NSTabView.h

tabViewItems

Returns the receiver’s array of tab view items.

- (NSArray *)tabViewItems

Discussion

A tab view keeps an array containing one tab view item for each tab in the view.

Availability
See Also
Declared In
NSTabView.h

tabViewType

Returns the tab type for the receiver.

- (NSTabViewType)tabViewType

Discussion

The available types are described in “Constants.”

Availability
Declared In
NSTabView.h

takeSelectedTabViewItemFromSender:

If sender responds to the indexOfSelectedItem method, this method invokes that method and selects the tab view item at the specified index. If sender does not respond to indexOfSelectedItem but is an instance of NSMatrix, this method uses the index of the matrix’s currently selected cell.

- (void)takeSelectedTabViewItemFromSender:(id)sender

Discussion

The location of the selected cell is a zero-based number, obtained by counting the number of cells up to and including the selected cell. Cells are counted from left to right and from top to bottom. For example in a 5-by-5 matrix, if the selected cell is three rows down in column five (location [2,4] in the matrix), the corresponding index would be 14.

Availability
Declared In
NSTabView.h

window

Returns the receiver’s window object, or nil if there is none.

- (NSWindow *)window

Discussion

If the receiver is not the currently visible tab view this method returns nil.

Delegate Methods

tabView:didSelectTabViewItem:

Informs the delegate that tabView has selected tabViewItem.

- (void)tabView:(NSTabView *)tabView didSelectTabViewItem:(NSTabViewItem *)tabViewItem

Availability
Declared In
NSTabView.h

tabView:shouldSelectTabViewItem:

Invoked just before tabViewItem in tabView is selected.

- (BOOL)tabView:(NSTabView *)tabView shouldSelectTabViewItem:(NSTabViewItem *)tabViewItem

Discussion

The delegate can return NO to prevent selection of specific tabs.

Availability
Declared In
NSTabView.h

tabView:willSelectTabViewItem:

Informs the delegate that tabView is about to select tabViewItem.

- (void)tabView:(NSTabView *)tabView willSelectTabViewItem:(NSTabViewItem *)tabViewItem

Availability
Declared In
NSTabView.h

tabViewDidChangeNumberOfTabViewItems:

Informs the delegate that the number of tab view items in tabView has changed.

- (void)tabViewDidChangeNumberOfTabViewItems:(NSTabView *)tabView

Availability
See Also
Declared In
NSTabView.h

Constants

NSTabViewType

These constants specify the tab view’s type:

typedef enum _NSTabViewType {
   NSTopTabsBezelBorder     = 0,
   NSLeftTabsBezelBorder    = 1,
   NSBottomTabsBezelBorder  = 2,
   NSRightTabsBezelBorder   = 3,
   NSNoTabsBezelBorder      = 4,
   NSNoTabsLineBorder       = 5,
   NSNoTabsNoBorder         = 6
} NSTabViewType;

Constants
NSTopTabsBezelBorder

The view includes tabs on the top of the view and has a bezeled border (the default).

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSNoTabsBezelBorder

The view does not include tabs and has a bezeled border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSNoTabsLineBorder

The view does not include tabs and has a lined border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSNoTabsNoBorder

The view does not include tabs and has no border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSBottomTabsBezelBorder

Tabs are on the bottom of the view with a bezeled border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSLeftTabsBezelBorder

Tabs are on the left of the view with a bezeled border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

NSRightTabsBezelBorder

Tabs are on the right of the view with a bezeled border.

Available in Mac OS X v10.0 and later.

Declared in NSTabView.h.

Availability
Declared In
NSTabView.h

Next Page > Hide TOC


© 2006 Apple Computer, Inc. All Rights Reserved. (Last updated: 2006-05-23)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.