Macos 单击“关闭”时删除窗口?

Macos 单击“关闭”时删除窗口?,macos,swift,cocoa,delegates,nswindow,Macos,Swift,Cocoa,Delegates,Nswindow,我已经创建了一个像这样的附加窗口- attachedWindow = MAAttachedWindow(view: castedView.view, attachedToPoint: point, inWindow: self.view.window!, onSide: MAPositionBottom , atDistance: 5.0) attachedWindow!.delegate = self attachedWindow!.makeKeyAndOrderFront(self) 我用

我已经创建了一个像这样的附加窗口-

attachedWindow = MAAttachedWindow(view: castedView.view, attachedToPoint: point, inWindow: self.view.window!, onSide: MAPositionBottom , atDistance: 5.0)
attachedWindow!.delegate = self
attachedWindow!.makeKeyAndOrderFront(self)
我用NSWindowDelegate-

        func windowDidResignKey(notification: NSNotification) {
        attachedWindow!.orderOut(self)
}
当我单击除attachedWindow之外的任何位置时,这都很有效,但当我单击此attachedWindow正下方窗口的标准关闭、缩小、缩放按钮时,则不会调用windowDidResignKey。因此,attachedWindow不会被删除,而是停留在屏幕上。我做错了什么?不应单击标准关闭、缩小、缩放按钮,应调用windowDidResignKey