---
title: "toolbar(_:itemIdentifier:canBeInsertedAt:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nstoolbardelegate/toolbar(_:itemidentifier:canbeinsertedat:)"
---

# toolbar(_:itemIdentifier:canBeInsertedAt:)

Asks the delegate for a Boolean value that indicates whether the toolbar can place the item at the specified position.

## Declaration

```swift
@MainActor optional func toolbar(_ toolbar: NSToolbar, itemIdentifier: NSToolbarItem.Identifier, canBeInsertedAt index: Int) -> Bool
```

## Parameters

- `toolbar`: The toolbar that contains the items.
- `itemIdentifier`: The identifier of the toolbar item to insert at the specified index.
- `index`: The proposed index at which to place the item. If the toolbar is removing the item, this value is doc://com.apple.documentation/documentation/Foundation/NSNotFound-4qp9h.

## Return Value

Return Value true to allow the toolbar to place the item at the specified location, or false to prevent the toolbar from placing the item in that location.

## Discussion

Discussion Implement this method to control the placement of items in the toolbar. During a drag operation, the toolbar calls this method to determine if the specified index is an acceptable location for the item. Return a Boolean value that indicates whether the new posiition is acceptable. Don’t use the index parameter to determine the final location of the toolbar item. During a drag operation, the toolbar can call this method multiple times, so the index value can change later.

## See Also

### Configuring the behavior of items

- [toolbarAllowedItemIdentifiers(_:)](appkit/nstoolbardelegate/toolbaralloweditemidentifiers(_:).md)
- [toolbarDefaultItemIdentifiers(_:)](appkit/nstoolbardelegate/toolbardefaultitemidentifiers(_:).md)
- [toolbarImmovableItemIdentifiers(_:)](appkit/nstoolbardelegate/toolbarimmovableitemidentifiers(_:).md)
- [toolbarSelectableItemIdentifiers(_:)](appkit/nstoolbardelegate/toolbarselectableitemidentifiers(_:).md)
