8

I have an NSDocument based app with autosave enabled.

I'd like to prevent this popup from showing: autosave popup

I have tried returning nil from NSWindow's –title, –representedFilename and –representedURL which hide the title effectively hide the title but have no effect on the downward facing disclosure indicator and the popup.

Is there a way I can prevent this popup from being presented?

pfandrade
  • 2,359
  • 15
  • 25

3 Answers3

10

I was able to prevent the button from being shown by overriding NSWindow's

+ (NSButton *)standardWindowButton:(NSWindowButton)windowButtonKind forStyleMask:(NSUInteger)windowStyle

and returning nil for NSWindowDocumentVersionsButton

pfandrade
  • 2,359
  • 15
  • 25
  • You need to override that in NSWindow subclass, not in NSWindowController subclass! Dont make the same mistake as I did (: – coolcool1994 Jan 17 '18 at 08:56
  • This also disable x, minimize, enlarge buttons right? My app just got rejected because of this. – coolcool1994 Jan 18 '18 at 01:43
  • You should return nil only for NSWindowDocumentVersionsButton. If you return nil for every button, no button will be displayed. – pfandrade Jan 18 '18 at 12:15
4

Return false from NSDocument's autosavesInPlace() override

Shoore
  • 49
  • 1
  • 1
  • 3
    The first line of the question mentions that autosave is enabled. Disabling a feature to avoid showing the button is not a correct answer. – pfandrade Jun 27 '17 at 09:09
1

You can also use a streamlined toolbar (wwdc2016)

  override func viewWillAppear() {
        super.viewWillAppear()

        self.view.window!.titleVisibility = .hidden  
  }

This removes also the title bar (but not the ones of tabbed windows)

Cue
  • 2,952
  • 3
  • 33
  • 54