Class

NSToolbarItemGroup

A group of subitems in a toolbar item.

Declaration

class NSToolbarItemGroup : NSToolbarItem

Overview

In an NSToolbarItemGroup, 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];

See Also

Items

class NSToolbarItem

An item in a window’s toolbar.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software