Reputation: 495
I'm programmatically creating an NSWindow
and have set its level
and other properties, but it doesn't appear on top of other apps. Using NSPanel
works, but I prefer not to use it since it doesn't support full-screen mode.
func openDummyWindow() {
let controller = NSWindowController()
let window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 800, height: 600),
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
backing: .buffered,
defer: false
)
// tried with .floating, .mainMenu but none worked
window.level = .screenSaver
window.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
let contentView = ZStack {
Color.clear
Text("Hello")
.font(.system(size: 72))
}
window.contentView = NSHostingView(rootView: contentView)
window.center()
controller.window = window
controller.showWindow(nil)
}
I've spent 6-7 hours trying, but no luck so far. It would be a huge help if someone could assist with this.
Upvotes: 0
Views: 51