So I have a status bar app that launches a small popover in the form of an NSPanel that has transient behaviour. However occasionally if I open say the Dropbox popover and then open my apps popover the dropbox menu will not disappear until I click a button in my popover. Which is strange because it only happens sometimes, and I am using [window makeKeyAndOrderFront:self]; when opening the popover. It works with Skypes drop down menu as well as a host of other status bar applications. There are a couple that won't dismiss when I open mine until I make an interaction in my popover. Is there a way to set focus to that button or something in the panel that might help force the other menus to close all the time?
Related
The contextual menu in one NSTextView in my app does work and imports a sketch made on my iPad / iPhone.
My problem is that when another of my app's windows is visible, the contextual menu in its NSTextView does not connect to the iOS device.
Also, when this second window is visible, the menu no longer works in the other window.
I posted a screen recording to YouTube here: https://youtu.be/qWMUGdL7O8g
I tried changing firstresponder to no avail.
I am attempting to create a preferences window using a storyboard, as was briefly demonstrated in WWDC 2014 Session 212 - Storyboards and Controllers on OS X. I have a "Preferences…" menu item that should show the preferences window when clicked. In Interface Builder, I connected the action segue for the preferences menu item to the preferences window controller. When I select the "Modal" style for the storyboard segue, then the preferences window is shown when the preferences menu item is clicked, but it is animated into view.
I would like the preferences window to be shown without any animation, like what happens when you open Xcode > Preferences or Safari > Preferences.
I have tried creating a custom NSStoryboardSegue and overriding the perform method in two different ways:
Call the showWindow: method of the destinationController (the NSWindowController).
This does not show the preferences window.
Actually, the window briefly flashes on screen behind all of the other windows, and then disappears.
Call the makeKeyAndOrderFront: method on the storyboard segue's window.
The window starts to appear, but disappears soon after. It seems that the window is being animated into view, but the window is abruptly hidden at the end of the animation.
How do I customize the segue to show the window without animating?
I'm building a Mac app that has no dock icon, but a status bar icon, so the only way of bringing it is from the status icon.
When the app is active i can bring my NSWindow on screen from the status icon without problems. The problem appears when the app looses focus, at that point the app hides itself. I don't know how to make the app again active when i click the status icon.
Thanks.
Have you tried NSApplication's activateIgnoringOtherApps:?
[NSApp activateIgnoringOtherApps:YES];
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"...