Demo of SetActivationPolicy bug on Mac
When we click Show Window
we expect the app to enter "Active State"
When we click Show Window
we instead see the app enter "Unexpected State" (See Reproduction Steps)
To workaround the user has to switch to another app temporarily and switch back to our app to get menu showing.
- App name appears in the menu bar
- App Window is on top
- App appears in dock
Active State is entered by:
House Icon
-> Show Window
which should run
NSApp.activate(ignoringOtherApps: true)
NSApp.setActivationPolicy(.regular)
- App name does not appear in the menu bar
- No App Window is visible
- App does not appear in dock
Accessory State is entered by closing the app window which triggers NSApp.setActivationPolicy(.accessory)
- The previous active app name appears in the menu bar
- App Window is on top
- App does not appear in dock
- Launch the app to begin in "Active State"
- Close app window to enter "Accessory State"
- Restart the app to begin in "Accessory State"
- Attempt to enter "Active State" by selecting
Show Window
in the menu dropdown - Notice the new "Unexpected State"
- Cmd-tab to another app and back brings the menu and name in top left corner