toolbar(_:itemForItemIdentifier:willBeInsertedIntoToolbar:)
Asks the delegate for the toolbar item associated with the specified identifier.
Declaration
@MainActor optional func toolbar(_ toolbar: NSToolbar, itemForItemIdentifier itemIdentifier: NSToolbarItem.Identifier, willBeInsertedIntoToolbar flag: Bool) -> NSToolbarItem?Parameters
- toolbar:
The toolbar for which the item is being requested.
- itemIdentifier:
The identifier for the requested item.
- flag:
True if the toolbar will insert the item immediately. If this parameter is False, provide a canonical representation for the item. For example, provide a version of the item suitable for display in the toolbar customization sheet.
Return Value
A new NSToolbarItem object, or nil if no toolbar item is available for the specified identifier.
Discussion
Use this method to create new NSToolbarItem objects when the toolbar asks for them. If your toolbar item uses a custom view, make sure that view is fully configured before you return the item. The toolbar becomes the owner of the returned item, but can display the item either in the toolbar or the customization palette.
Don’t recycle toolbar items; always provide a new instance, even if the toolbar previously asked for an item with the same identifier.
See Also
Related Documentation
- Toolbar Programming Topics for Cocoa