title: Window close button hijacking on Snow Leopard
body: <p>I'm working on an NSDocument-based app with multiple documents per window (tabs). This means I need to handle closing of windows myself so that I can review the documents belonging to the window before it's closed. In order to do this, I've accessed the NSWindow's close button using <code>standardWindowButton:NSWindowCloseButton</code> and set the target/action of this button to my method instead of the standard (and private) <code>_close:</code> method.</p>
  
  <p>This works great on Lion, but on Snow Leopard it causes issues. Whenever a modal dialog is displayed, the close button gets disabled as expected. But when the modal dialog is dismissed, on Snow Leopard the close button never gets reenabled. I've tried reenabling it programmatically afterwards using <code>[closeButton setEnabled:YES]</code> etc, but it doesn't seem to have any effect.  I've confirmed that this only happens when I've changed the target/action of the close button.</p>
  
  <p>Any ideas on how to avoid this behavior on Snow Leopard, or maybe an alternative way of hijacking the close button? What is it that controls the enabled state of the toolbar buttons? Maybe I could override something there?</p>