Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you make the Application window open when the dock icon is clicked?

Tags:

cocoa

I'm surprised this doesn't happen automatically, but I would like my applications window to open automatically when the Dock icon is clicked.

Just to clarify, when i open the app, the window automatically opens, but when I click the cross for the window but leave the App running, the window won't open when i click the dock icon.

like image 904
Joshua Avatar asked May 02 '09 14:05

Joshua


People also ask

Can an app window be minimized by clicking its Dock icon Mac?

In MacOS if you use HyperDock you can press Shift+Click on Dock icon, and it will Hide the application. It's equivalent to pressing keyboard shortcut Cmd+H - Hide.

How do I minimize a window on a Mac with clicking icon?

Answer: A: System Preferences > Dock & Menu Bar. Change "Double-click a window's title bar to": minimize.

How do I add an application icon to my Mac Dock?

Method 1: Drag Application Icon to Dock With Finder active, look at the menu bar across the top of the screen. Click “Go,” then select “Applications” from the list. Your Applications folder will open in a Finder window. Locate the app that you want to put in the Dock, then click and drag its icon into the Dock.

How do I add an app to my Dock on my computer?

Go to Finder > Applications and open the Office app you want. In the Dock, Control+click or right-click the app icon and choose Options > Keep in Dock.


1 Answers

Implement - (BOOL)applicationShouldHandleReopen:(NSApplication *)theApplication hasVisibleWindows:(BOOL)flag in your app delegate. Check the documentation for the details of the return value.

Document based apps and non-document based apps behave slightly differently. If there are no open windows when the dock icon of a document based app is clicked then it will create a new document. If there are no open windows when the dock icon of a non-document based app is clicked then it will do nothing.

like image 74
Benedict Cohen Avatar answered Oct 19 '22 11:10

Benedict Cohen