menubar app behavior vs full screen app spaces (mac os 10.7/lion) - objective-c

When you have an app in fullscreen mode (in a fullscreen space) the menubar is hidden unless you "nudge" the top of the screen. However if you hit the spotlight hotkey the menubar politely shifts down into the screen with the spotlight search bar. Excellent.
I am migrating a statusbar/faceless application that I wish to have emulate this spotlight's menubar handling. Under snow leopard the app responds to a system hotkey by displaying a menu (it has a NSStatusBar item and I call popUpStatusItemMenu). Under Lion when the app is in fullscreen mode/space however, the menubar remains hidden for the fullscreen app (note however that the hot key IS bringing up the statusbar item and using the keyboard I can activate individual actions on the menu -- I just can't see the menu pop up).
To reiterate - anyone know how spotlight (under lion) displays the menubar in response to a hotkey? Or should I be asking when a better way to handle my UI would be under Lion?
thanks,

I feel reasonably certain that Spotlight is using private interfaces to change the presentation mode of the login session. You can change the presentation mode for an application using -[NSApplication setPresentationOptions:] (or the deprecated-but-still-available Carbon equivalent SetSystemUIMode()), but these explicitly only propagate to the login session from the “frontmost faceful application”.
I suggest filing a suggestion for an API to request that certain UI elements (menu bar, dock) are shown if they’re currently in autohide mode from the background.

Related

Continuity camera contextual menu issue

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.

How do you hide the menu bar in a Cocoa app?

How do you programmatically hide the menu bar in a cocoa app? I would like to make full use of the screen area.
There are two good ways I know of to do this.
1
In Cocoa, you can call the NSMenu class method setMenuBarVisible: to show or hide the menu bar.
As of this writing, the documentation for the NSMenu class does not tell you the following additional information.
The menu bar will only be hidden for the app that calls this method.
The Dock will also be hidden at the same time.
(This is true at least in 10.9 and I have not tested any other versions.)
This is useful when you want to use an app in a full screen way where you have a cover window, a borderless window the size of the screen.
The nice feature of this (as opposed to playing with LSUIElement settings) is that your app can continue to be in the application switcher cycling, as well as visible in the Dock when other apps are active.
This allows users to still activate a full screen app through the Dock or application switcher.
That means you can still use your app's Dock menu to access a preferences window for your app or other features.
This is incredibly convenient if your app is indeed a full screen cover window that runs at a window level higher than other apps, but you still want to make preferences and the ability to quit your app available, and you want your app's visual functionality available when other apps are active.
2
Another option is via NSApplication's method setPresentationOptions: with the arguments from NSApplicationPresentationOptions enum, such as option NSApplicationPresentationHideMenuBar
With this approach be very wary of reading the documentation, although it gives you additional options, and is still app-specific only, you need to know that some of the options are mutually exclusive. There are rules you must follow, or you get nothing but exceptions spewed to the console.
3 There is a 3rd and crappy option. If you have a helper app that is a daemon, you can use it to change your app's LSUIElement state and basically relaunch your app. It's dumb and it takes you out of the app switcher completely, which is great if you really are writing something that should not be there, but that is rare.
There is also the NSView enterFullScreenMode:withOptions: method, although most apps for which that would be appropriate prior to 10.7 should probably use the modern full-screen-window API on 10.7 and later.

Hide app icon in dock when minimized

I am new at Mac OSx development.
The app that I am creating requires removing the app icon from the dock throughout the application. The app allows minimizing and closing of the app window. Relaunching or reopening of the closed or minimized app window is done by clicking the app's icon from the status bar.
I was able to set the dock icon to be disabled during app launching; however, when the app is minimized (clicking the minimize button), it captures the image of the app's current window and adds it to the dock. I don't want that to occur. The app should not add any item to the dock.
Questions:
Does Apple allow removal of the app's re-launcher image from the dock when minimized?
If Apple allows this, how can I hide or remove the app from the dock?
Any help would be a big help! Thanks!
You cannot disable the display of a proxy tile when your window is minimized -- that's the primary way that users will restore a minimized window. If you'd rather that the window disappear entirely when it's not being used, disable minimization (in the window's flags) and have the user close the window instead.

Use LSUIElement (aka no Dock icon) but retain the "File, Edit, View" menubar?

I want my app to have:
Menubar extra icon (by the clock)
App Menubar ("File, Edit, View, Etc")
I do not want my app to have:
Dock Icon
Is this possible? I am deploying for 10.6 and 10.7 via the Mac App Store if that matters.
Setting LSUIElement in the info.plist file removes the dock icon, but it also removes the menubar.
NSApplication's setActivationPolicy might be what you are after.
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
Please note the discussion:
Currently, NSApplicationActivationPolicyNone and
NSApplicationActivationPolicyAccessory may be changed to
NSApplicationActivationPolicyRegular, but other modifications are not
supported.Needs links to running application
As per NSApplicationActivationPolicyAccessory's documentation you may need to programmatically ensure that the menu bar appears.
You could create two "separate" applications. One that has a dock icon and menu items,the other one has just the icon by the clock.
When you click on the icon by the clock it launches the dock application. When you close the dock application the 'background' application stays running.
If that model will work for you then that's the way to go. But I would weigh that effort against what File-Edit-View will do for you.

Cocoa Application with Menubar but no Dock Icon / switch menu

This is yet one more of those "how to switch from running with a dock icon to running without one" questions with a twist.. I don't want the dock icon but I do want a menu bar when the application is at the front. Is that possible?
Running an application with LSUIElement set to 1 in the plist will launch the application without a dock icon, not showing up in the command-tab switch list and without a menu.
You can switch from that mode to the "normal" mode with all three switched on via SetSystemModeUI from 10.2 onwards and via NSApplication setApplicationActivationPolicy since 10.6, but crucially there is no way back to the previous mode (go figure).
So one way around this would be to launch with LSUIElement = 1 and then activate the menu bar when the application gets the focus and deactivate it on the application losing the focus.. alas I can't find a way of doing that.
Can anybody help?
Best regards,
Frank
I too was looking for a solution, but it turned out to be quite simple:
In the project file Info.plist need to add the key
"Application is agent (UIElement)" = YES
Unfortunately, this is not possible. You can only transform the process type in one direction (from a background app to a foreground app) and not the other way.