Class

NSToolbar

NSToolbar and NSToolbarItem provide the mechanism for a titled window to display a toolbar just below its title bar, as shown below:

Overview

A toolbar

Symbols

Creating an NSToolbar Object

init(identifier: String)

Initializes a newly allocated toolbar with the specified identifier.

Toolbar Attributes

var displayMode: NSToolbarDisplayMode

The toolbar’s display mode.

var showsBaselineSeparator: Bool

A Boolean value that indicates whether the toolbar shows the separator between the toolbar and the main window contents.

var allowsUserCustomization: Bool

A Boolean value that indicates whether users are allowed to modify the toolbar.

var allowsExtensionItems: Bool

A Boolean value that indicates whether the toolbar can add items for Action extensions.

var identifier: String

The receiver’s identifier.

var items: [NSToolbarItem]

An array containing the toolbar’s current items, in order.

var visibleItems: [NSToolbarItem]?

An array containing the toolbar’s currently visible items.

var sizeMode: NSToolbarSizeMode

The toolbar’s size mode.

Getting and Setting the Delegate

var delegate: NSToolbarDelegate?

The toolbar’s delegate.

Managing Items on the Toolbar

func insertItem(withItemIdentifier: String, at: Int)

Inserts the specified item at the specified index.

func removeItem(at: Int)

Removes the specified item.

var selectedItemIdentifier: String?

Returns the identifier of the receiver’s currently selected item, or nil if there is no selection.

Displaying the Toolbar

var isVisible: Bool

A Boolean value that indicates whether the toolbar is visible.

Toolbar Customization

func runCustomizationPalette(Any?)

Runs the receiver’s customization palette.

var customizationPaletteIsRunning: Bool

A Boolean value that indicates whether the receiver’s customization palette is running (in use).

Full Screen Accessory View Settings

var fullScreenAccessoryView: NSView?

The toolbar’s full screen accessory view.

var fullScreenAccessoryViewMaxHeight: CGFloat

The maximum height of the toolbar’s full screen accessory view, in points.

var fullScreenAccessoryViewMinHeight: CGFloat

The minimum height of the toolbar’s full screen accessory view.

Autosaving the Configuration

var autosavesConfiguration: Bool

A Boolean value that indicates whether the receiver autosaves its configuration.

var configuration: [String : Any]

A dictionary containing configuration information for the toolbar.

Validating Visible Items

func validateVisibleItems()

Called on window updates to validate the visible items.

Constants

NSToolbarDisplayMode

These constants specify toolbar display modes and are used by the displayMode property.

NSToolbarSizeMode

These constants specify toolbar display modes and are used by the sizeMode property.

Notifications

static let NSToolbarDidRemoveItem: NSNotification.Name

Posted after an item is removed from a toolbar.

static let NSToolbarWillAddItem: NSNotification.Name

Posted before a new item is added to the toolbar.

Relationships

Inherits From

Conforms To