Files
5GUIs-1/Sources/5GUIs/Utilities/WindowEnvironmentKey.swift
Helge Heß caa6434312 5 GUIs - initial drop
Ooh LA LA ...
2020-10-01 16:43:06 +02:00

29 lines
512 B
Swift

//
// WindowEnvironmentKey.swift
// 5 GUIs
//
// Created by Helge Heß on 28.09.20.
//
import SwiftUI
extension EnvironmentValues {
var window : NSWindow? {
set {
self[WindowEnvironmentKey.self] =
WindowEnvironmentKey.WeakWindow(window: newValue)
}
get {
self[WindowEnvironmentKey.self].window
}
}
}
struct WindowEnvironmentKey: EnvironmentKey {
struct WeakWindow {
weak var window : NSWindow?
}
public static let defaultValue = WeakWindow(window: nil)
}