Alex Rivera | Logout

Overriding "Edited" in window title for NSDocument

Asked 2012-04-27T02:36:26.293
10

How do I prevent a window title from displaying "Edited" for an NSDocument which is dirty?

I'm managing saving and autosaving myself, using a web service, and just don't want the distraction in the title bar.

I've tried overriding:

  • NSDocument's -isDocumentEdited and -hasUnautosavedChanges always to return NO.
  • -[NSWindowController setDocumentEdited] to do nothing, or always to use NO regardless of the parameter's actual value.
  • -[NSWindowController synchronizeWindowTitleWithDocumentName] to do nothing.
  • -[NSWindow setDocumentEdited] to do nothing, or always to use NO regardless of the parameter's actual value.

In all cases, the title bar still changes to Edited when I make changes to a saved document.

If I override -[NSDocument updateChangeCount:] and -[NSDocument updateChangeCountWithToken:forSaveOperation:] to do nothing, I can prevent this from happening, but it affects saving, autosaving, and other document behaviors, too.

I also tried this:

[[self.window standardWindowButton: NSWindowDocumentVersionsButton] setTitle:nil];

That displayed a blank string instead of Edited, but the dash still appeared – the one which normally separates the document name and Edited.

Any idea how to pry apart this part of the window from the document?

Edit
Report

1 Answer

1

Have you tried overriding NSDocuments - (BOOL)hasUnautosavedChanges in addition to overriding - (BOOL) isDocumentEdited?

answered 2012-04-30T20:51:00.310

Your Answer