NSToolbarItem Mac OS X 10.0

This class represents the controls that populate toolbars in the user interface. By default, a toolbar item is an icon with a label attached. This icon functions as as simple button. Like instances of NSButton, an NSToolbarItem object sends an action message to a target when the user clicks the item. To initialize a toolbar item, we use the method initWithItemIdentifier:. The identifier is simply a string used to uniquely identify the toolbar item. AppKit has a number of prebuilt toolbar items that are used for common tasks, such as opening the color panel or starting a print job. To take advantage of these standard toolbar items, initialize the toolbar item with one of the identifier strings listed in the constants herein.

The second type of toolbar item is a custom NSView assigned to the toolbar item. The method setView: can be used to create a view in Interface Builder (or programatically) with a small set of controls suitable for a toolbar, and then create a toolbar item out of this view. This allows you to put standard AppKit controls (such as sliders or radio buttons) in the toolbar.


@interface NSToolbarItem : NSObject <NSCopying, NSValidatedUserInterfaceItem>
 // Initializers
   - (id)initWithItemIdentifier:(NSString *)itemIdentifier;
 // Accessor Methods
   - (void)setMinSize:(NSSize)size;
   - (NSSize)minSize;
   - (void)setTag:(int)tag;
   - (int)tag;
   - (void)setMaxSize:(NSSize)size;
   - (NSSize)maxSize;
   - (void)setLabel:(NSString *)label;
   - (NSString *)label;
   - (void)setTarget:(id)target;
   - (id)target;
   - (void)setPaletteLabel:(NSString *)paletteLabel;
   - (NSString *)paletteLabel;
   - (void)setEnabled:(BOOL)enabled;
   - (void)setAction:(SEL)action;
   - (SEL)action;
   - (void)setImage:(NSImage*)image;
   - (NSImage *)image;
   - (void)setToolTip:(NSString*)toolTip;
   - (NSString *)toolTip;
   - (void)setView:(NSView *)view;
   - (NSView *)view;
   - (void)setMenuFormRepresentation:(NSMenuItem *)menuItem;
   - (NSMenuItem *)menuFormRepresentation;
 // Instance Methods
   - (BOOL)allowsDuplicatesInToolbar;
   - (BOOL)isEnabled;
   - (NSString *)itemIdentifier;
   - (NSToolbar *)toolbar;
   - (void)validate;
 // Methods Implementing NSCopying
   - (id)copyWithZone:(NSZone *)zone;
 // Methods Implementing NSValidatedUserInterfaceItem
   - (SEL)action;
   - (int)tag;

    Part II: API Quick Reference
    Chapter 13. Foundation Classes