I am coding a Mac app that is an NSPopover
on the right side of the menu bar (Application is agent(UIElement)
is set to YES
). I allow the user to detach the popover by clicking and dragging it downward, which puts the app inside of a window. This is working fine; however, when the app is dragged off of the menu bar and made into a window, I would like my app's icon to come up in the dock, as well as show app-specific menus on the left side of the menu bar, as if Application is agent(UIElement)
is set to NO
. Conversely, when the window is closed and the app is returned to a popover in the menu bar, I would like my app's icon to disappear from the dock and no longer show app-specific menus on the left side of the menu bar (Application is agent(UIElement)
is set back to YES
).
From this question, I understand that changing Application is agent(UIElement)
at runtime isn't possible. However, the answer given is in Objective-C, and the last function appears to be depreciated since OS X 10.9. How can I make my app have the same behavior as changing Application is agent(UIElement)
at runtime using Swift?
I know that showing the app icon/menu bar menus would happen in windowDidBecomeMain
and hiding the app icon/menu bar menus would happen in windowWillClose
.
Thanks.