Class

NSToolbar

An object that manages the space immediately below a window's title bar and above your app's custom content.

Declaration

class NSToolbar : NSObject

Overview

Toolbars manage controls and content that apply to the content of a window. Items in the toolbar are represented by NSToolbarItem objects.

Topics

Creating an NSToolbar Object

init(identifier: NSToolbar.Identifier)

Initializes a newly allocated toolbar with the specified identifier.

Configuring the Toolbar Contents

var delegate: NSToolbarDelegate?

The toolbar’s delegate.

protocol NSToolbarDelegate

A set of optional methods implemented by toolbar delegates to configure the toolbar and respond to changes.

Toolbar Attributes

var identifier: NSToolbar.Identifier

The receiver’s identifier.

var displayMode: NSToolbar.DisplayMode

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 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: NSToolbar.SizeMode

The toolbar’s size mode.

Managing Items on the Toolbar

func insertItem(withItemIdentifier: NSToolbarItem.Identifier, at: Int)

Inserts the specified item at the specified index.

func removeItem(at: Int)

Removes the specified item.

var selectedItemIdentifier: NSToolbarItem.Identifier?

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.

Deprecated
var fullScreenAccessoryViewMaxHeight: CGFloat

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

Deprecated
var fullScreenAccessoryViewMinHeight: CGFloat

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

Deprecated

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

enum NSToolbar.DisplayMode

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

enum NSToolbar.SizeMode

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

Notifications

class let didRemoveItemNotification: NSNotification.Name

Posted after an item is removed from a toolbar.

class let willAddItemNotification: NSNotification.Name

Posted before a new item is added to the toolbar.

Relationships

Inherits From

Conforms To

See Also

View

protocol NSToolbarItemValidation

Validation of a toolbar item.