Hide app icon in dock when minimized - objective-c

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.

Related

What API can be used to hide OSX Dock when you drag a window towards it

Idea is simple(stolen from Ubuntu): autohide Dock when you drag window toward it and begin to overlap it. Turn autohiding off and show Dock when window is moved out of area when Dock is located.
What API can be used to achieve that ?
update:
managing autohide possible from command line this way but it's horrible
defaults write com.apple.dock autohide -bool true
killall Dock
Well, when the Dock is configured to (always) stay visible, the Window Manager will simply refuse to position the window directly under the Dock. It prevents users from putting stuff to where they can't reach. (Not every user is a power user; not every user knows the Dock can be hidden and since the Dock has no click-throughs...)
The system will hide the Dock when the app goes fullscreen. But, again, the system takes care of it.
Aside from directly mucking around with the user's Dock preferences (never change a user's preference for a third-party app behind their back!) like you mentionned; it can't be done legitematly.
There's is no API to control the Dock... at best, you can only suggest a tile to represent your app when present on the Dock.

Re-create Cocoa application menubar

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.

OSX Lion -- NSEvent when Launchpad is entered

I am writing a Mac app that uses a window which is glued to the foreground of the screen. I am listening for the NSWindowDidResignKeyNotification to detect when it is appropriate to hide the window.
For almost every purpose -- including when a different application enters focus -- this works perfectly.
On OSX Lion there is an idiosyncrasy. When my window is open and glued to the foreground, and then the user selects the Launchpad icon from the dock to expand the Launchpad, my window stays in the foreground, even over Launchpad. It appears that Launchpad is implemented as some sort of screen overlay rather than a window that would take focus.
Does anyone have any solution to detect when Launchpad enters focus so that I can dismiss my window?

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.

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

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.