I have an app which must run all the time (if the user agree whit this).
When the user quit the app, I transform the foreground app into a LSUIElement (the app only has a menu bar icon, the dock icon and the menu disappear).
I have an options in the menu item which works ok and transform the LSUIElement into a foreground app (I use the functions [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]
and [NSApp activateIgnoringOtherApps:YES]
).
My problem appear when the user double click on the app. I use again the [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular]
in the delegate method applicationWillUnhide:(NSNotification *)notification
, and all works well except the menu which doesn't appear. If I go to another app, and then I came back the menu appear. I try different methods but I wasn't able to find a good one.
I want to know is a delegate method which is called when the user double clicks on the app, or what is the function from NSApplication
which is called in that moment, because I think using the setActivationPolicy:
in the applicationWillUnhide
function is to late.