Reputation: 2003
According to Mac Dock documentation: "The Dock keeps applications on its left side, while Stacks and minimized windows are kept on its right. If you look closely, you'll see a vertical separator line that separates them."
Meaning, once the application is minimized, you have a NEW dock icon in the right side, and you need to click on it in order to maximize your application.
However, applications like Chrome and Finder behave differently: if you click on the the LEFT icon (the "main" application's icon), it will also maximize the application!
I have created my own mac application, and I'd like to make it behave like Chrome: meaning once it is minimized, if you click on either the left or right dock icons, it will maximize. How can I do that programmatically?
[I am attaching a dock screenshot. You can see both Chrome "main" icon and "minimized" icon next to it. Both icons will respond and will maximize the window.
However other applications (like TextEdit, and also the one I programmed in XCode): only the minimized icon maximizes them. The "main" icon does nothing.]
How can I make both icons maximize my application programmatically?
Thanks a million!
Nili
Upvotes: 3
Views: 1299
Reputation: 14160
Clicking on the Dock icon calls:
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag
Reopen your windows in this message handler.
It is send to the Application Delegate and is part of the NSApplicationDelegate
protocol.
Upvotes: 0
Reputation: 2003
Need to implement applicationShouldHandleReopen in order to open minimized windows from the "main" icon
- (BOOL)applicationShouldHandleReopen:(NSApplication *) __unused theApplication hasVisibleWindows:(BOOL)flag
{
if (!flag){
[[self window] makeKeyAndOrderFront:self];
}
return YES;
}
Upvotes: 2