SwiftUI Notification that macOS MenuBarExtra app lost focus
I’m building a MenuBarExtra app that allows users to paste items into other apps from a context menu. I need to detect when the context menu has lost focus (keyWindow status) or another app has gained key status before I initiate the paste. Using NSWindow.didResignKeyNotification
works when debugging in Xcode but does not work when the app is published as the notification arrives before the other app has gained focus.