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

Changing shortcuts in Cocoa applications System
There have been a few good hints about changing the menu shortcut keys in Carbon apps by using a hex editor on the Localized.rsrc file. What about the Cocoa apps? I couldn't find a hint here about it, but it's ridiculously easy.

First, make sure you have the Developers Tools installed. Start the application "Interface Builder" located in /Developer/Applications.

Right click on the application you wish to modify and select "Show Package Contents." Navigate to Contents -> Resources -> English.lproj. You may wish to make a backup of the application first, just in case...

Drag the file "MainMenu.nib" to the Interface Builder icon on the dock to open it. You will see the menu bar of your application presented for editing. Just double-click on the various elements to change them. You can double-click on the hotkey letter to change it to something else. Save it and restart your application to enjoy the new shortcuts.
    •    
  • Currently 5.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,373 views]  

Changing shortcuts in Cocoa applications | 8 comments | Create New Account
Click here to return to the 'Changing shortcuts in Cocoa applications' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Only for some...
Authored by: metafeather on Jul 19, '02 11:48:43AM

I was wondering if this meant that we could actually change the interfaces of apps too, as well as the keys, and for some this seems to be the case - don't like a layout/text field label/icon you can change that too!

However, can't get this to work for all the applications I have tried (definitely all Cocoa).

In most cases the Contents folder is not accessibly except via the Terminal.
Once navigated to in Interface Builder > Open menu the .nib files will not open.

Tried copying / changing the permissions on the files (each .nib is actually a folder), but this didn't change anything.

Perhaps some developers have just not opted to protect their code in some way?



[ Reply to This | # ]
Only for some...
Authored by: james_sorenson on Jul 19, '02 12:16:31PM

I'm not very experienced with Project Builder, but there may be an option to protect the compiled code to prevent people from stealing portions of the code for their own projects.

A pity. Can you list a program or two that does this so I can look into it? I'm curious if there is a way around it. In my example, I wanted to add cmd-return as a hot-key to sending a message in Icy Juice (ICQ clone). It worked great.



[ Reply to This | # ]
Only for some...
Authored by: chmod007 on Jul 19, '02 12:26:29PM

No, you are incorrect...Code is never exposed. Dried frozen objects stored in nibs are exposed, but some developers delete the files that are vital for this to work from the nib files. Maybe they do it to save disk space, or maybe to avoid tampering with the interface. It's a pity.



[ Reply to This | # ]
The reason some nibs won't...
Authored by: Anonymous on Jul 19, '02 06:10:18PM

... open is because they are missing the property list that describes teh classes within the NIB file. This file is not used at runtime, but is used by IB.

The problem lies with the nibtool command line tool -- it has a bug that removes this file whenever it processes a NIB. Apple uses the command line tool to automate the localization process.

But, likely, these files won't come back as it does occupy a bunch of space across the entire system.



[ Reply to This | # ]
How to do it from the command line
Authored by: placain on Jul 21, '02 06:57:26PM
Here's how to do it from the command line, without opening any nib files or anything like that:

Let's say you want to reassign Send Message in Mail to be command-s:

% defaults write com.apple.Mail NSUserKeyEquivalents '{"Send Message" = "@s";}'


@ = command 
$ = shift
~ = option
^ = control


[ Reply to This | # ]
How to do it from the command line
Authored by: james_sorenson on Jul 22, '02 12:18:50AM

How did you figure out that trick with adding a new key to the Mail preferences to alter keyboard shortcuts? Is this particular to just Mail, or do all Cocoa apps accept custom key configurations from a preference file? If so, do you know of an easy way to get the name of the commands from the source to assign the keys? If it's this easy, one could write a program that could be a general shortcut manager for all Cocoa apps.



[ Reply to This | # ]
How to do it from the command line
Authored by: hombre on Aug 01, '02 03:53:24PM

Such an application exists. It is called ReKey.



[ Reply to This | # ]
...and the return key?
Authored by: dm2243 on Jul 22, '02 02:04:31PM

tried "@\\" but that doesn't work.



[ Reply to This | # ]