Class

NSToolbarItem

An item in a window’s toolbar.

Declaration

class NSToolbarItem : NSObject

Overview

If an NSToolbarItem has an NSSearchField instance as its view, that search field automatically has its minimum and maximum size adjusted to the system-specified standard values (currently 140 and 240 points).

Topics

Creating a Toolbar Item

init(itemIdentifier: NSToolbarItem.Identifier)

Initialize the receiver with a given identifier.

init(itemIdentifier: NSToolbarItem.Identifier, barButtonItem: UIBarButtonItem)

Creates a toolbar item with property values from the specified bar button item.

Managing Attributes

var toolbar: NSToolbar?

The toolbar that is using the receiver.

var label: String

The receiver’s label.

var paletteLabel: String

The label that appears when the receiver is in the customization palette.

var toolTip: String?

The tooltip used when the receiver is displayed in the toolbar.

var title: String

The title of the toolbar item.

var menuFormRepresentation: NSMenuItem?

The receiver’s menu form representation.

var itemMenuFormRepresentation: UIMenuElement?

The receiver’s menu form representation in Mac apps built with Mac Catalyst.

var tag: Int

The receiver’s tag.

var target: AnyObject?

The receiver’s target.

var action: Selector?

The receiver’s action.

var isBordered: Bool

A Boolean value that determines whether the toolbar item has a bordered style.

var isEnabled: Bool

A Boolean value that indicates whether the receiver is enabled.

var image: NSImage?

The image of the receiver.

var view: NSView?

The receiver’s view.

var minSize: NSSize

The receiver’s minimum size.

var maxSize: NSSize

The receiver’s maximum size.

Validation

func validate()

This method is called by the receiver’s toolbar during validation.

var autovalidates: Bool

A Boolean value that indicates whether the receiver is automatically validated by the toolbar.

Controlling Duplicates

var allowsDuplicatesInToolbar: Bool

A Boolean value that indicates whether the receiver can be represented in the toolbar at more than one position.

Constants

Standard Identifiers

NSToolbarItem defines the following standard toolbar item identifiers.