windowDidResignKey
windowDidResignKey is a delegate method in AppKit used by macOS applications to respond when a window loses its status as the key window. The key window is the window that receives keyboard input and is typically the active window for user interaction.
When a window becomes key, it gains the primary focus for keyboard events. A different window or
This method is part of the NSWindowDelegate protocol and is optional. Developers implement it to perform tasks
In the notification parameter, you can access the affected window with notification.object, which is the NSWindow
func windowDidResignKey(_ notification: Notification) {
if let window = notification.object as? NSWindow {
// Respond to the window losing key status
}
}
Related delegate methods include windowDidBecomeKey and windowWillClose, which handle the opposite event and other window lifecycle