- Inherits from:
- NSView : NSResponder : NSObject
- Package:
- com.apple.yellow.application
Note: The NSTabView class and its supporting class NSTabViewItem are under development. If you want to use these classes, you will have to instantiate them programmatically because Interface Builder does not yet include support for them. |
An NSTabView provides a convenient mechanism for presenting information in a multi-page format. The view is distinguished by a row of tabs that give the visual appearance of folder tabs, as shown in the figure below. 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.
An NSTabView can support a multi-page format without visible tabs. For example, instead of tabs, you might use a pop-up menu or radio buttons, similar to those shown in the illustration, to let the user select from several view pages. When a tab view is drawn with tabs (the default), the border must be bezeled. When a tab view is drawn without tabs, the view can have a bezeled border, a lined border, or no border.
An NSTabView keeps a zero-based array of NSTabViewItems, one per tab in the view. A tab view item provides access to a tab's color, state, label text, initial first responder, and associated view.Your application can supply each tab view item with an optional identifier object to customize tab handling. For more information, see the documentation for NSTabViewItem.
Tab label text defaults to the default font and font size used for standard interface items, such as button labels and menu items. When you invoke setFont to change the tab view's font, tab height and width is adjusted automatically to accommodate a new font size. If the view allows truncating, tab labels are truncated as needed.
NSTabView defines delegate messages to allow the delegate to control or react to changes in selection and changes in the number of tabs:
false
to
prevent the selection.These constants specify the tab view's type:
Constant | Description |
TopTabsBezelBorder |
The view includes tabs and has a bezeled border (the default) |
NoTabsBezelBorder |
The view does not include tabs and has a bezeled border |
NoTabsLineBorder |
The view does not include tabs and has a lined border |
NoTabsNoBorder |
The view does not include tabs and has no border |
BackgroundTab |
Description forthcoming. |
BottomTabsBezelBorder |
Description forthcoming. |
LeftTabsBezelBorder |
Description forthcoming. |
PressedTab |
Description forthcoming. |
RightTabsBezelBorder |
Description forthcoming. |
SelectedTab |
Description forthcoming. |
- Constructors
- NSTabView
- Adding and removing tabs
- addTabViewItem
- insertTabViewItem
- removeTabViewItem
- Accessing tabs
- indexOfTabViewItem
- indexOfTabViewItemWithIdentifier
- numberOfTabViewItems
- tabViewItemAtIndex
- tabViewItems
- Selecting a tab
- selectFirstTabViewItem
- selectLastTabViewItem
- selectNextTabViewItem
- selectPreviousTabViewItem
- selectedTabViewItem
- selectTabViewItemAtIndex
- takeSelectedTabViewItemFromSender
- Modifying the font
- font
- setFont
- Modifying the tab type
- setTabViewType
- tabViewType
- Manipulating the background
- drawsBackground
- setDrawsBackground
- Determining the size
- minimumSize
- contentRect
- Truncating tab labels
- allowsTruncatedLabels
- setAllowsTruncatedLabels
- Assigning a delegate
- setDelegate
- delegate
- Event handling
- tabViewItemAtPoint:
public NSTabView()
public NSTabView(NSRect frameRect)
public void addTabViewItem(NSTabViewItem tabViewItem)
See Also: insertTabViewItem, numberOfTabViewItems, removeTabViewItem, tabViewItemAtIndex, tabViewItems
public boolean allowsTruncatedLabels()
true
if
the tab view allows truncating for labels that don't fit on a
tab. The default is false
. When
truncating is allowed, the tab view inserts an ellipsis, if necessary,
to fit a label in the tab. See Also: setAllowsTruncatedLabels
public NSRect contentRect()
public Object delegate()
See Also: setDelegate
public boolean drawsBackground()
true
if
the tab view draws a background color when the tab view type is NoTabsNoBorder
. If
the tab view uses bezeled edges or a line border, the appropriate
background color for that border is used. See Also: setTabViewType, setDrawsBackground
public NSFont font()
See Also: setFont
public int indexOfTabViewItem(NSTabViewItem tabViewItem)
NSArray.NotFound
if
the item is not found. A tab view keeps an array
containing one tab view item for each tab in the view-this is
the array that is searched. The returned index is base 0.See Also: indexOfTabViewItemWithIdentifier, insertTabViewItem, numberOfTabViewItems, tabViewItemAtIndex
public int indexOfTabViewItemWithIdentifier(Object identifier)
NSArray.NotFound
if
the item is not found. A tab view keeps an array
containing one tab view item for each tab in the view-this is
the array that is searched. The returned index is base 0.See Also: indexOfTabViewItem, insertTabViewItem, numberOfTabViewItems, tabViewItemAtIndex
public void insertTabViewItem(
NSTabViewItem tabViewItem,
int index)
See Also: indexOfTabViewItem, indexOfTabViewItemWithIdentifier, numberOfTabViewItems, tabViewItemAtIndex
public NSSize minimumSize()
See Also: setTabViewType
public int numberOfTabViewItems()
See Also: indexOfTabViewItem, tabViewItems
public void removeTabViewItem(NSTabViewItem tabViewItem)
See Also: addTabViewItem, insertTabViewItem, tabViewItems
public void selectFirstTabViewItem(Object sender)
See Also: selectTabViewItem
public void selectLastTabViewItem(Object sender)
See Also: selectTabViewItem
public void selectNextTabViewItem(Object sender)
See Also: selectTabViewItem
public void selectPreviousTabViewItem(Object sender)
See Also: selectTabViewItem
public void selectTabViewItem(NSTabViewItem tabViewItem)
See Also: insertTabViewItem, selectedTabViewItem
public void selectTabViewItemAtIndex(int index)
See Also: insertTabViewItem, selectedTabViewItem
public void selectTabViewItemWithIdentifier(Object identifier)
See Also: setIdentifier (NSTabViewItem), identifier (NSTabViewItem), selectTabViewItemAtIndex, selectedTabViewItem
public NSTabViewItem selectedTabViewItem()
null
if
no item is selected. If there is a delegate and
the delegate supports it, sends the delegate the tabViewShouldSelectTabViewItem message.See Also: selectTabViewItemAtIndex
public void setAllowsTruncatedLabels(boolean allowTruncatedLabels)
See Also: allowsTruncatedLabels
public void setDelegate(Object anObject)
See Also: delegate
public void setDrawsBackground(boolean flag)
NoTabsNoBorder
. If the
tab view has a bezeled border or a line border the appropriate background
for that border is used.See Also: setTabViewType, drawsBackground
public void setFont(NSFont font)
See Also: allowsTruncatedLabels, font, setAllowsTruncatedLabels
public void setTabViewType(int tabViewType)
Constant | Description |
TopTabsBezelBorder |
The view includes tabs and has a bezeled border (the default) |
NoTabsBezelBorder |
The view does not include tabs and has a bezeled border |
NoTabsLineBorder |
The view does not include tabs and has a lined border |
NoTabsNoBorder |
The view does not include tabs and has no border |
See Also: tabViewType
public NSTabViewItem tabViewItemAtIndex(int index)
See Also: indexOfTabViewItem, insertTabViewItem, tabViewItems
public NSTabViewItem tabViewItemAtPoint(NSPoint point)
public .NSArray tabViewItems()
See Also: numberOfTabViewItems, tabViewItemAtIndex
public int tabViewType()
public void takeSelectedTabViewItemFromSender(Object sender)
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.
public abstract void tabViewDidChangeNumberOfTabViewItems(NSTabView tabView)
See Also: numberOfTabViewItems
public abstract void tabViewDidSelectTabViewItem(
NSTabView tabView,
NSTabViewItem tabViewItem)
public abstract boolean tabViewShouldSelectTabViewItem(
NSTabView tabView,
NSTabViewItem tabViewItem)
false
to
prevent selection of specific tabs.public abstract void tabViewWillSelectTabViewItem(
NSTabView tabView,
NSTabViewItem tabViewItem)