import AppKit import SwiftUI final class FloatingPanel: NSPanel { init(contentView: some View) { super.init( contentRect: NSRect(x: 0, y: 0, width: 440, height: 380), styleMask: [.titled, .closable, .fullSizeContentView, .nonactivatingPanel], backing: .buffered, defer: false ) isFloatingPanel = true level = .floating titleVisibility = .hidden titlebarAppearsTransparent = true isMovableByWindowBackground = true isReleasedWhenClosed = false animationBehavior = .utilityWindow hidesOnDeactivate = false collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary] backgroundColor = .windowBackgroundColor self.contentView = NSHostingView(rootView: contentView) center() } override var canBecomeKey: Bool { true } override func cancelOperation(_ sender: Any?) { close() } }