I would like it to close on Command ⌘–W as per the standard. There is a close button on window and it’s enabled so I’m not sure what is eating the close command keyboard shortcut.
The content view is a webview if that makes any difference.
I’ve implemented windowWillClose and windowShouldClose but none of them are hit during debugging when pressing Command ⌘–W.
Does the File menu at the top of the screen flash when you press Command ⌘–W? That might indicate whether something is eating the key event before it goes to the normal responder chain. For example, I believe it is possible for some javascript in your webview could be eating the event.
Normally the Command ⌘–W is sent to the firstResponder (usually the control where keyboard focus is) and then along the responder chain. This document might be helpful: http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/EventArchitecture/EventArchitecture.html%23//apple_ref/doc/uid/10000060i-CH3-SW10
Some things to try:
Make a text field outside your webview and see if Command ⌘–W works when that text field has focus. That might implicate the webview.
Turn on
NSObjCMessageLoggingEnabled.This produces lots of output, but can show you exactly what methods are called after you press Command ⌘–W.