Next Page > Hide TOC

NSToolbarItemGroup Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/AppKit.framework
Availability
Available in Mac OS X v10.5 and later.
Companion guide
Declared in
NSToolbarItemGroup.h

Overview

NSToolbarItemGroup is a subclass of NSToolbarItem which contains subitems. The views and labels of the subitems are used, but the parent's attributes take precedence.

To configure an instance of NSToolbarItemGroup, you first create the individual toolbar items that will be the subitems:

NSToolbarItem *item1 = [[[NSToolbarItem alloc] initWithItemIdentifier:@"Item1"] autorelease];
NSToolbarItem *item2 = [[[NSToolbarItem alloc] initWithItemIdentifier:@"Item2"] autorelease];
[item1 setImage:[NSImage imageNamed:@"LeftArrow"]];
[item2 setImage:[NSImage imageNamed:@"RightArrow"]];
[item1 setLabel:@"Prev"];
[item2 setLabel:@"Next"];

and then put them in a grouped item:

NSToolbarItemGroup *group = [[[NSToolbarItemGroup alloc] initWithItemIdentifier:@"GroupItem"] autorelease];
[group setSubitems:[NSArray arrayWithObjects:item1, item2, nil]];

In this configuration, you get two grouped items, and two labels. This differs from ordinary NSToolbarItem objects because they are attached—the user drags them together as a single item rather than separately.

If you set a label on the parent item:

[group setLabel:@"Navigate"];

you get two grouped items with one shared label.

If instead you set a view on the parent item, you get two labels with one shared view:

[group setView:someSegmentedControl];

Tasks

Working with Subitems

Instance Methods

setSubitems:

Sets the subitems for the receiver.

- (void)setSubitems:(NSArray *)subitems

Parameters
subitems

An array of instances of NSToolbarItem objects that form the subitems for the receiver.

Discussion

You should call this method to set the subitems before returning the item to the toolbar. NSToolbarItemGroup objects cannot contain other NSToolbarItemGroup objects as subitems.

Availability
Declared In
NSToolbarItemGroup.h

subitems

Returns the subitems for the receiver.

- (NSArray *)subitems

Return Value

The subitems for the receiver.

Discussion

By default, an NSToolbarItemGroup instance has an empty array of subitems.

Availability
Declared In
NSToolbarItemGroup.h

Next Page > Hide TOC


© 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-04-11)


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.