Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Add 'Hide App' dock menu to Cocoa apps Desktop
If you are like me your Desktop is often cluttered with way too many windows. I use the Hide command or its option-click counterpart quite a bit to free up screen space and clutter. Command-option-clicking in the Dock is also handy for hiding all. For one app, however, that's not always best either.

With a few simple Interface Builder connections you can add a Hide App dock menu item to almost any Cocoa application. Sadly I couldn't get this to work with a few Apple apps I use often. The Terminal is one, Mail is another.

If you have the Developer Tools installed and would like to add a "Hide Application" dock menu to your favorite Cocoa applicaiton, read the rest of the article.

[Editor's note: I followed these instructions and they worked perfectly for the app I tested (Okito Composer). Even if you're not interested in a new "Hide" dock menu, this is a great tutorial that shows how easy it is to modify an applications behavior with InterfaceBuilder.]

INSTRUCTIONS:
  1. Locate in the Finder, the app you want to add the Hide command to. Make a copy before you start! Also quit the app if it's running.

  2. Control click it and select 'Show Package Contents'.

  3. In the resulting window open Contents/Resources. Open the .lproj file for your language.

  4. This step might be tricky. Find the ".nib" file that is named the same as the application you are working on. OR one with the word "Main" in it. If you don't see anything like this you may have to try several of these before you get the right one. The one you are looking for is the one that when opened in Interface Builder (IB) [editor's note - just double-click the icon in the finder to launch IB] has an icon called "File's Owner" under the Instances tab. If you don't see it, close this one and try opening another nib file. If you never find one you can't do this trick with that app. Sorry! If you did find it, cool!

  5. In IB select Show Palettes from the Tools menu. Click on the "Cocoa Menus" icon (the leftmost icon in the top row). Now drag the picture of the miniature menu bar (located below and right of all the sample bars with text) to the window with the File's Owner.

  6. Double click the new menu's name (under its icon) and change it to 'dockMenu'.

  7. Double click the new menu icon to open the menu for editing. You only need one menu item here so delete any extras (by clicking once on the item and hitting DELETE).

  8. Double click the remaining menu item and rename it to 'Hide theAppName'. Replacing theAppName with whatever you'd like the menu item name to be -- "Hide XYZ_App" or whatever its called is a good choice. This is how the menu will in appear in the Dock.

  9. Control Click and drag a connection (illustrated by a blue line) to the "File's Owner" icon in the other window.

  10. The info panel will open showing a list of commands. Double click the one that says 'hide:'

  11. Now Control click the File's Owner icon and drag a connection to the new menu icon in the same window (the one you created by dragging the icon earlier). In the Info Panel double click "dockMenu".

  12. Save the Nib file, Quit, Launch your Application and check out the new command in the Dock Menu.
Things to note:
  • If the Application already has a custom dockMenu, don't create a new one with new connections, simply add the Hide menu item and make a connection to the hide: command as detailed above.
  • I was unable to open several Nib files contained in several Apple Applications. I am not sure why this is. Maybe they use an old nib file format, anyone know about this?
Enjoy...

Let me know what you think: Mithrandir@dr.com or stop by my website: http://BadDog.2y.net
    •    
  • Currently 2.33 / 5
  You rated: 5 / 5 (3 votes cast)
 
[12,975 views]  

Add 'Hide App' dock menu to Cocoa apps | 3 comments | Create New Account
Click here to return to the 'Add 'Hide App' dock menu to Cocoa apps' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
this is why...
Authored by: bhines on Oct 26, '01 10:31:36PM
You can't open many apple nibs because they were distributed stripped. Here is the discussion and explanation from the projectbuilder-users list. See also This post. (the password is archives/archives) Lots of inside info gets posted on the various apple lists, macosx-dev, projectbuilder-users and cocoa-dev. -Ben From: Scott Herz Sender: projectbuilder-users-admin@lists.apple.com Date: Mon, 22 Oct 2001 14:37:14 -0700 Space considerations on the CD led us to strip the .nib directories of their design time information. You can put these nibs back together using the following procedure: 1) Make a back up of the nib, burry it in a 3 foot deep, lead-lined shaft in your back yard 2) Make a new Cocoa nib, save it somewhere 3) Within your newly created nib, there is a classes.nib file. Copy this file into your AddressBook nib. The AddressBook nib should at least open now. However, DO NOT change any connections while editing this nib. Doing so will corrupt the nib (since it's using bogus classes info at this point). Oh yeah, one more step. 4) File your bug. Scott. On Monday, October 22, 2001, at 12:38 PM, tlr@mac.com wrote: I used to believe that IB was intended to open (and edit) NIB files. Turns out that it doesn't always work: I tried today to open (a copy of) the nib files in the Address book app, in order to correct an annoying bug in that one (again...) IB just refuses to open them (any of them). Double-clicking has no effect at all, except launching IB if necessary. Using the open command in menu gives an alert: "impossible to open the file 'xxx.nib'" (I translate from french). No reason, no argument: this sort of message is really a shame... Could anyone please tell me if he encounters the same bug?

[ Reply to This | # ]
Edit the DockMenus.plist
Authored by: Reeko on Mar 18, '02 11:55:20PM

I had just tried to do the same thing before I found your post, that is add a 'Hide' dock menu for all apps. So far it works for all apps in my dock, cocoa, carbon, and classic.
Edit the file /System/Library/CoreServices/Dock.app/Contents/Resources/English.lproj/DockMenus.plist
of course, back it up first.

on line 204, add the following text:
<dict>
<key>command</key>
<integer>1006</integer>
<key>dynamic</key>
<integer>0</integer>
<key>name</key>
<string>Hide</string>
</dict>
<dict>
<key>command</key>
<integer>1007</integer>
<key>dynamic</key>
<integer>1</integer>
<key>name</key>
<string>Hide Others</string>
</dict>

then kill the dock, or logout and log back in.

When you right click on any dock app, you'll see a 'Hide' option at the bottom, and if you hold Option, you'll get 'Hide Others'



[ Reply to This | # ]
Edit the DockMenus.plist
Authored by: Reeko on Mar 19, '02 12:03:43AM

One slight correction. Add this block underneath the one I posted above:

<dict>
<key>command</key>
<integer>2000</integer>
<key>separator</key>
<true/>
</dict>

or else you'll lose your 'Quit' menu item (woops!)



[ Reply to This | # ]