Can NSTrackingSeparatorToolbarItem be used from SwiftUI?

Viewed 483

I'm attempting to create a macOS application that has a sidebar, and I'd like to be able to use the new .sidebarTrackingSeparator toolbar item. However, it's not accessible as part of ToolbarItemPlacement, and the following code:

 NSApp.keyWindow?.toolbar?.insertItem(withItemIdentifier: .sidebarTrackingSeparator, at: 0)

places it, but the item isn't visible.

Is there any way to place a button in the toolbar such that it's visible on top of the sidebar like Xcode's left-collapse item?

1 Answers

If you want a button on the left side of the sidebarTrackingSeparator, the index of the separator must be larger the first button. So try to insert the separator with an index of 1 instead of 0.

Related