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.
Related
I have a borderless window with a webview in it, which is always on top.
I want to create a NSWindow which is:
Always on top
Does not take the focus from the current foreground app
Does enable user mouse interaction (without forcing the user to switch focus to it - aka "click on it twice")
The problem I have atm is that to interact with the window (e.g. see hover effect, or click a link in the webview), the user has to click the window (which gives it focus) and only then the hover effect shows.
How can I make a window like iTunes mini player which doesn't take the focus from the current app - but also interacts with mouse? (see screenshots below)
Thanks!!
To receive mouseEntered:, mouseMoved: and mouseExited: events even when your app is not active, you must add a tracking area to some view in your window and set the tracking area's properties accordingly.
Take a look at NSTrackingArea.
You'll probably want to add a tracking area with the options NSTrackingActiveAlways and NSTrackingMouseEnteredAndExited.
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)
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.
I am building a Cocoa Mac application that runs in the background but has a main window.
To make it run in the background I've set "Application is background only" to "YES".
I built a system tray:
If you close the main window, you can re-open it by clicking "open".
I have however some issues with the layering of windows:
When I start the application, the main window opens however it appears in the background, behind any other windows or applications I have open at the time.
Clicking on "open" doesn't bring the window to the foreground. It opens it correctly if it was closed, however it stays behind any windows.
Clicking on preferences or about has the same issue. It opens the correct window but it appears behind any other windows.
On my main window there is a textfield. I can click on it, the cursor blinks as if I am ready to type. But when I type it actually types in some other background window! For example if I have TextWrangler open in the background, it will type there instead of the textfield...
Here is my code for handling the "open":
- (IBAction)show:(id)sender {
[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:sender];
}
Note that IF I set "Application is background only" to "NO" (which means I have a dock icon appearing), then clicking on "open" brings the window to the foreground as expected. And typing in the textfield works as expected.
Instead of background only, I think you want Application is agent (UIElement) set to YES. Background only is for application not intended to be visible for users.
Background only (LSBackgroundOnly YES) is intended for faceless background applications, Accessory (LSUIElement YES) is intended for background applications with a UI and status menu (menu extra/accessory menu/etc. - the name changes...).
An accessory will not appear in the dock, have a standard menu bar, or appear in the Finder's Force Quit dialog. It can be "active" and can have the key window.
Though it does not have a standard menu bar bizarrely (maybe a bug) if a MainMenu is declared in the XIB then it will respond to key shortcuts when it is active. To avoid this make sure you have no MainMenu or use [NSApp setMainMenu:nil] when you wish to disable the shortcuts.
The whole background/accessory/application/active/etc. area is not exactly well-defined, be prepared for "fun"...
How can I show an NSWindow when clicking on an NSStatusItem, such that it shows over other applications when appearing, but without causing them to lose active status?
I have seen MAAttachedWindow, and it is neat but it does not show on top of other applications unless its own application is active.
I would check out this excellent tutorial and sample project:
Cocoa Popup window in the Status bar
That example shows how to "attach" a window to a status bar item, but you could position the window wherever you want. Basically, if you define your app as a LSUIElement you can display floating utility windows despite your app never activating or showing a dock icon, and other apps still remain key.
if you use MAAttachedWindow, you can set the winow level as NSStatusWindowLevel. Then it will show on top of other application.