Achieve NSTrackingSeparatorToolbarItem in SwiftUI?

In AppKit, you can use the NSTrackingSeparatorToolbarItem item to create a toolbar item that automatically attaches to the separator in a split view.

However, I didn't find an equivalent in SwiftUI yet. I tried to add a .toolbar modifier to each individual view, however, that didn't seems to achieve the effect. All the item are just on the right side of the window.

Any native SwiftUI way to achieve this, or do I have to go back to using AppKit windows?

Replies

Same question here...

I have been puzzling on this for many hours. How is this supposed to work Apple? It is nice that you think up new magic stuff, but please add some instructions on how it is supposed to be used, using real-world examples. I watched your WWDC session, but still it is a puzzle.

If an apple engineer is reading this: please enlighten us...
I would also like to know if there is a SwiftUI solution for this.
All the new and cool WWDC2020 stuff for BigSur is based on AppKit. And there is currently no SwiftUI implementation for this part. But I'm also interested in this and how to achieve this with SwiftUI. I'm a really big fan of SwiftUI and how it works but for now it seems that SwiftUI is more a iOS/iPadOS thing then a macOS thing.

But maybe this one will do the trick. - Haven't tested this yet...
Code Block
NSApp.keyWindow?.toolbar?.insertItem(withItemIdentifier: .sidebarTrackingSeparator, at: 1)