blob: a23687439c845935faa89d5969872ef638c09b42 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import SwiftUI
struct HostingWindowKey: EnvironmentKey {
typealias Value = () -> NSWindow? // needed for weak link
static let defaultValue: Self.Value = { nil }
}
extension EnvironmentValues {
/// This can be used to set the hosting NSWindow to a NSHostingView
var hostingWindow: HostingWindowKey.Value {
get { return self[HostingWindowKey.self] }
set { self[HostingWindowKey.self] = newValue }
}
}
|