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

Prevent accidental window closure in a given app System
I use (and switch between) my "favorite browser of the week" (Firefox at the moment) and iChat quite regularly. Until recently, I would also regularly upset myself by closing an active iChat window when I meant to close a browser tab ... it usually went something like this: open a bunch of web pages in tabs, start reading them, get 'pinged' for a reply in an iChat conversation, hit Command-Tab to activate iChat, but keep reading the web page. Finish the web page, hit Command-W and *poof* goes the active iChat conversation!

iChat very nicely asks you if you're sure you want to quit with an active conversation. It not so nicely does not ask if you simply close an active chat window! I was so irked at myself that I set off to find a solution, starting with hacking the code in XCode. But halfway through that exercise, I thought of a much simpler solution...

In addition to assigning new keyboard shortcuts, Panther's Keyboard Shortcuts tab (on the Keyboard & Mouse preferences panel) will also let you reassign an existing keyboard shortcut. So I clicked the "+" sign, set the Applications drop-down to iChat (which I had already quit), entered Close for the Title, and then set the shortcut to Shift-Command-W and hit Add.

Presto, when I re-launched iChat, the Close command had become Shift-Command-W! Now when I invoke my stupidity and hit Command-W in iChat instead of Firefox, I'm simply greeted with a beep, letting me know I tried to do something stupid. I made this change on Saturday, and it probably saved five or six iChat window this weekend alone (yes, I used to do this a lot!).

This trick will, of course, work in any application ... with most applications, you'll also see your re-assignment in the "All Applications" section of the shortcuts list.

Edit: On my home machine, the iChat shortcut doesn't show in the list of customized shortcuts; on my PowerBook, it shows up fine. I guess I've got a corrupted Keyboard pref on the home box. As the comment notes, just delete the custom assignment to get things back to normal...
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[8,273 views]  

Prevent accidental window closure in a given app | 21 comments | Create New Account
Click here to return to the 'Prevent accidental window closure in a given app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Prevent accidental window closure in a given app
Authored by: arg on Mar 22, '04 11:38:03AM

Unfortunately you can't get things back to normal by redefining the Close Window command to command-w as the Keyboard Pref Pane forbids creating any custom keyboard commands using only the command key as a modifier. (It's true. Try it if you don't believe me.) Anyway, the way to get things back to normal is to delete the custom shortcut in the Keyboard Pref Pane. This will revert iChat to its original, non-customized state.



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: gdsimms on Mar 22, '04 12:01:32PM

D'oh!

I had gotten accustomed to editing .nib files to make my own keyboard shortcuts, and I hadn't noticed this preferences feature at all in panther.

Keep those "obvious" hints coming for us who are stuck in old ways of doing things.



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: schneb on Mar 22, '04 12:03:35PM

I wish the keyboard shortcut customization would work on other applications like Photoshop. There is one deep-seated menu item that I use quite often and it does not have one!

Man, I wish we had ResEdit for OSX.



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: osxpounder on Mar 22, '04 12:10:25PM

I share your wish; I tried to map a keyboard shortcut to Fetch's "Rename File or Directory..." because I do that so often, but I can't get the shortcut to "take". Even after restarting the Mac.

---
--
osxpounder



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: dogboy on Mar 22, '04 12:12:30PM

Just create an action, click on the actions menu and choose "Insert Menu Item".

Then assign whichever key combo you like.

Or buy Photoshop CS which has re-definable keys.



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: Tom Robinson on Mar 22, '04 02:24:22PM
Man, I wish we had ResEdit for OSX.
If it's a Carbon app you can always hack it with ResEdit under Classic...

[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: CyborgSam on Mar 22, '04 01:31:25PM

Unsanity's Menu Master can also do tricks like this:
http://www.unsanity.com

Here's the blurb from the ReadMe:

Menu Master is a haxie that allows you to change or remove menu shortcut keys in any application with ease. It takes about 15 seconds to learn how to use Menu Master, and saves you lots of time later because you can use the shortcuts you defined and do not bother remembering which ones the developer of the software invented for you. Additionally, you can set shortcuts to any menu item that had no shortcuts, or remove shortcuts from menu items. Menu Master gives you a complete control over your menus, all just for affordable US $10.



[ Reply to This | # ]
Ten bucks?!
Authored by: Brian Kendig on Mar 22, '04 06:23:47PM

Why pay $10 for something that can be done in System Preferences for free?



[ Reply to This | # ]
Ten bucks?!
Authored by: aranor on Mar 23, '04 05:36:26AM

Because MenuMaster makes it much easier to do, and doesn't place limits on what you can set as your shortcut?



[ Reply to This | # ]
Quickfix for keys you can't edit in the GUI interface
Authored by: alec kinnear on Mar 22, '04 02:11:07PM

there seem to be a lot of rules about what keys combinations you can and cannot edit in the Keyboard preference pane.

there is a simple way around these limitations however.

open up the ~/Library/Preferences/.GlobalPreferences.plist with Property List Editor.

find and open up NSUserKeyEquivalents. edit away as many keyboard shorcuts as you like without apple sitting on your shoulder and telling you which you can and cannot use.

the modifier symbols: command is @
shifts is $
control is ^
option is ~

more info available here: http://www.macosxhints.com/article.php?story=20010415090359962

what i have used this hint for is to stop my browsers from quitting on command-quit (they are now all set to command-control quit) as i use the command-tab to flip between html editor and browsers all day long and tired of accidentally hitting command-q and losing all my open files or web pages.

you do have to replace the command-quit shortcut on an application by application basis. doesn't take long to duplicate the command and paste.

you can create dummy keys for each application in the GUI Keyboard Preference pane which makes the Property List Edit go faster.

no need to work on each applications own plist files. all menus fixable in globalpreferences.plist (had some trouble with Adobe applications though).

don't forget to quit and relaunch applications to see their new keyboard commands show up (visible in the menu).

[ Reply to This | # ]

Prevent accidental window closure in a given app
Authored by: connell on Mar 22, '04 04:33:33PM

Is there a special syntax to use unicode characters? I want to use the delete key, as decribed here: www.macosxhints.com/article.php?story=20010415090359962

but everytime I try to add unicode character U0008 (for the delete key) all I see is the letter U in the menu, and the keyboard shortcut accepts U, not the delete key.

Ideas??



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: ericasadun on Mar 22, '04 08:55:27PM

You need to use a backslash when working with unicode.

e.g. <code>defaults write com.apple.calculator NSUserKeyEquivalents -dict-add "Area\U2026" "^A"</code>



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: connell on Mar 22, '04 10:07:58PM

Thanks. I finally used this:

defaults write com.apple.finder NSUserKeyEquivalents '{"Secure Empty Trash"="@$~\U0008";}'

Unfortunately, entering \U0008 for delete directly in the property list editor or by editing the plain text com.apple.finder.plist did not work. So I had to do it in the terminal, which for some reason when I ran the above command removed all my previous shortcuts which I had entered in via the system prefs.

But now it works!



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: tim1724 on Mar 23, '04 12:23:32AM
Try using this format when you want to add new items without deleting old ones:

defaults write com.apple.finder NSUserKeyEquivalents -dict-add "Secure Empty Trash" "@$~\U0008"

---
Tim Buchheim

[ Reply to This | # ]

Detect last window closed
Authored by: UCMacGuru on Mar 22, '04 05:19:08PM

On a related topic: any ideas how to detect if the last window of an app is closed and prompt to user? There used to be a MacOS 9 control panel called "Quit It" that did that but no such animal for X.

It would sure cure a not a blank stares from our more Windows centric users.



[ Reply to This | # ]
Log Out change doesn't work?
Authored by: Brian Kendig on Mar 22, '04 07:06:08PM

Changing Close to Shift-Command-W worked just fine for me, so I tried changing Log Out of AIM to Shift-Command-L (because I keep hitting Command-L thinking I'm in Safari, and it logs me out of AIM)...

But that change seems to be ignored, even though I'm certain I entered it properly. Anyone know why the hotkey for Log Out of AIM can't be changed?



[ Reply to This | # ]
Prevent accidental Firefox closure
Authored by: kirbysdl on Mar 22, '04 07:17:14PM
Barely related, but there is a nice little extension for Firefox (that probably works with other Mozilla family browsers) that prompts you before closing a window with multiple tabs. This has saved me on several occasions from closing a window accidentally.

http://texturizer.net/firefox/extensions/#tabwarning

[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: CarlRJ on Mar 22, '04 08:06:46PM

I'd like to add a large thank you to the author. I've used the new ability to set keyboard shortcuts (it's nice to have cmd-shift-M as Zoom, for Terminal windows, to compliment cmd-M for Minimize), and I've also been extremely annoyed, once a week or so, when my finger strayed from cmd-W to cmd-Q in Safari and I suddenly lost several dozen pages I'd not yet read... but until seeing this hint, I hadn't put the two together and realized that one could remap the existing "Quit Safari" command from cmd-Q to cmd-option-Q). This will save me a lot of grief in the future -- Thanks!

-- Carl, who still thinks Safari needs an "Are you sure?" dialog when quitting with multiple tabs open.



[ Reply to This | # ]
Prevent accidental window closure in a given app
Authored by: ericasadun on Mar 22, '04 09:13:27PM

It's easy enough to add an "Are you sure" dialog to Safari.

Build a new window in Interface Builder. Add text ("Are you sure")
and two buttons (Cancel, OK).

Connect the Quit menu item (in MainMenu.nib) to the Window
(make key and order front) and connect OK to File's Owner/Terminate. Have Cancel close the window.



[ Reply to This | # ]
Proper dialog box text
Authored by: derrickbass on Mar 22, '04 11:34:47PM

Well maybe this doesn't really matter for when you modify an application yourself, but one of the things that sets Macs apart from Windows is the useful text in dialog boxes and on the buttons. (I've seen dialog boxes in Windows with triple negatives! Very hard to decide if OK or Cancel is what you want!)

The text should be: "Are you sure you want to quit?" and the buttons should be "Quit" and "Cancel". (The reason you use "Quit" instead of "OK" is so the user does not have to read and understand the text. "OK" is almost never appropriate.)



[ Reply to This | # ]
Proper dialog box text
Authored by: kps on Mar 23, '04 10:15:35AM