Sent to request a new toolbar item; returns a toolbar item of the identified kind for the specified toolbar.
- macOS 10.0+
- Mac Catalyst 13.0+
The toolbar for which the item is being requested.
The identifier for the requested item.
trueif the item will be immediately inserted into the toolbar. If
falsethe toolbar item is being requested for display in the toolbar customization sheet and should always be enabled or provide some other canonical representation. If you ignore this parameter the same toolbar item will be used in the toolbar and in the customization sheet.
The toolbar item for the specified toolbar and identifier. Return
nil to indicate that the identified kind of toolbar item is not supported. When an item is requested again, you may return the same
NSToolbar object returned earlier or a different instance.
Implement this method to create new toolbar item instances. This method is called lazily on behalf of a toolbar instance, which must be the sole owner of the toolbar item. A toolbar may ask again for a kind of toolbar item already supplied to it, in which case this method may return the same toolbar item it returned before or a different one. If your delegate services multiple toolbars, each attached to a different window, it is best to return a different item for each toolbar—an
NSToolbar object can only be in one toolbar at a time.
If the item is a custom view item, the
NSView object must be fully formed when the item is returned. Do not assume that the returned item is going to be added as an active item in the toolbar, as it could be that it will be used only in the customization palette. (The customization palette makes a copy of the returned item.)