2

When an NSDocument is marked as having changes and the user closes it, a sheet is shown with options for Don't Save, Close and Save.

How can I intercept or disable the Save button?

I have overridden -saveDocument: and -saveDocumentAs: but these are not called when saving from this warning sheet?

I am trying to warn users that the document will be saved into a new file format (if I know the document is in an old format) and would also like to prevent saving documents in the demo version of the software.

Is there anyway to modify this path so I can show my own sheet instead?

Trygve
  • 1,317
  • 10
  • 27

1 Answers1

4

You can intercept it by overriding NSDocument's canClose(withDelegate:shouldClose:contextInfo:). The method is called when user is going to close a document. Thus, you can create your own alert sheet there before calling super's.

1024jp
  • 2,058
  • 1
  • 16
  • 25