Fix cycle windows bug on non-US keyboards

Aug 13, '02 10:49:37AM

Contributed by: sapporo

Apparently, the Cycle Windows shortcut for Cocoa applications is broken for some non-US keyboard layouts in Mac OS X 10.1. This is a known bug, but wasn't fixed in the Jaguar preview shown at WWDC earlier this year. It may or may not be fixed in the final release. Luckily, it's quite easy to fix this for your favourite application if you have the developer tools installed (I wish I had tried earlier!).

Read the rest of the article for the how-to...

The method to handle window cycling in Cocoa applications is a private method of NSApplication called _cycleWindows:. To enable its functionality, locate the .nib file containing the main menu of the application you want to modify - it's usually located in /Applications -> SomeApplication -> Contents -> Resources -> English.lproj (assuming you want to fix the English version). It might be named MainMenu.nib if you're lucky, or otherwise if not (you could try MailViewer.nib for Mail and OmniWeb.nib for OmniWeb). I recommend Terminal to navigate there, because in this special case, it's actually the most convenient.

Don't forget to backup the nib file, then double-click it to open it with InterfaceBuilder. If it won't open, that's probably because the info.nib and classes.nib files in MainMenu.nib/ have been removed. Just find an info.nib and classes.nib file in some other application, copy them to MainMenu.nib/ and remove them after you're done. Strange, but it usually works!. Create a new menu item in the Window menu. I usually call it Cycle Windows and assign the keyboard shortcut Command-^, because I'm using a German keyboard. It's probably best to chose the key left to the "1" key, since that's how it's supposed to work anyway.

Now, select the First Responder icon in the Instances tab and switch to the Classes tab. Command-I should bring up the inspector window for the FirstResponder class, and Command-1 will show its Attributes. Select the Actions tab, and create an action named _cycleWindows: if it doesn't already exist. Select the Instances tab and Control-drag from your newly created menu item to the First Responder icon. This will show the Connections for your menu item. With target highlighted on the left side, chose _cycleWindows: on the right hand side and click the Connect button. That's it. Save the nib and open the application you manipulated. If all went well, you'll discover your new menu item in the Window menu, and cycling windows finally works the way it should!

Disclaimer: You should probably not do this at all. If you do, I will not take any responsibility.

Comments (8)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20020813104937703