I am developing a OS X app and want it to run without dock icon but with a icon in the menubar. I have added the menubar utility and tried to set the following code in applicationDidFinishLaunching:
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
It works well, except that the app will still show the window when launched. How to prevent this? I can't set the LSUIElement in Info.plist because I want this behavior to be changeable in the runtime.
Thanks in advance!
Edit
It seems that the Visible At Launch is unchecked by default... I am using storyboard so I created a new project, choose Main.storyboard -> Window Controller Scene -> Window, and found it unchecked, but the window will still open automatically.
image (cannot post it directly with <10 reputation)
Related
NSWindow which is run as modal(runModalForWindow)from a launch agent which has NSUIElement set to 1( no dock icon or menu bar) is not accessible, Accessibility inspector is not displaying info for this window or button from that window.
We need this window to be accessible to automate it through AXElements,
Can we set some properties of Window or button to make it accessible( as per documentation they should be accessible). Are there any properties that we need to set, since this is launched from an agent without menu bar or dock item.
Thanks,
swetha
The alert was shown from awakeFromNib which was causing issue, after moving the alert display code to applicationDidFinishLaunching, the alert is properly accessible through AXElements.
I fear that is a mountain lion bug.
The steps to reproduce it are:
Create a status bar application;
Add a menu item that triggers a method;
In this method, show a window with orderFront: (window created through xib);
Archive the application and add it as login item;
Try to trigger the menu item and you'll see no window appearing.
To make this possibile, in the xib file I disable release when closed and visible at launch.
To make it show I have to launch again the application. I notice the same for applications installed from the app store like watts.
I'm making a statusbar application and load a new xib containing the main window for the application when clicking on a statusbar menu item. However, in the process I deleted the application menu bar. I don't see a way to hook up the NSMenu object I created in the interface builder.
The window loads just fine, and the status bar icon is still present, but when I make the main window the key window, the application menu bar doesn't change, it just shows the previous app that was active.
I have followed the instructions/suggestions here and here, but neither of them work. Is there some other step I've missed?
Thanks!
The behavior you're describing is normal for background applications. If you don't have an icon in the Dock, you don't get your own menubar, even if you have a window in the foreground.
My application uses NSStatusItem to be visible to the user.
So I set 'Application is agent (UIElement)' to YES, which basically hides the menu bar of the application, and hides the icon from the dock.
Now, I didn't delete the menu bar, so I can still react to shortcuts like cmd+W to close the preference window, or cmd+q to quit the application. The problem is, that anytime I use such a command, the menubar get's messed up.
I've noticed that other Apps which run in the background, like Growl 2, have the same issue.
I have no idea how to fix this.
Hopefully someone of you can help me
I'm running Mountain Lion.
thanks!
HINT
It probably has something to do with the 10.8 SKD. I have never noticed this issue before in any application.
How about move the whole Window menu to be Application menu submenu and then hide it?
You will still receive shortcuts and the highlited menu will be the application menu that is by anyway there (i suppose so, how else you will open preferences window? also shortcut?).
I have a problem which is driving me nuts.
Suppose you have an app with a window that is set to "Visible at Launch". When you launch the app, the window immediatly appears.
If you add this simple app to the login startup items list, when you log in, the app is automatically launched and you have the window just opened in front of you. This is what was happening in Snow Leopard.
If you repeat the same steps in Lion, as soon as you log-in, the app is launched but the window does not appear.. It seems that the NIB doesn't get loaded.
To make it appear you have to click on the app icon in the dock (even if the app is already launched).
This happens even if you specify [NSApp disableRelaunchOnLogin] according to Apple documentation here.
Things become worst if your app has NSUIElement = 0 and therefore it doesn't have neither an icon in the Dock, nor a Menubar. In this case there's no way to make the window to appear.
Is there a way to obtain the expected behavior of Snow Leopard? Am I missing something?