1

Like Safari app, in a macOS Swift project I would like to let users to open more than a window and possibly use tabbed browsing to switch from a window to another. The app starts with a blank window and don't need to save or open documents.

A Document Based application seems perfect to me for handle more than a window but I don't want users have to handle documents. How can I disable or hide, if possible, the Open and Save document features?

Edit: if possible, I would like to disable this popup also:

enter image description here

Cue
  • 2,952
  • 3
  • 33
  • 54

2 Answers2

0

It is very simple - just remove (delete) the Open, Open Recent..., Save, Save as... menu items from the menu XIB. If you don't want a title bar, simply untick the "Title" checkbox for the window in the XIB, though that makes the window difficult to move.

enter image description here

If you have a title bar, to override "Untitled", you could

override var displayName: String! {
    get {
        return "Anything you like, even \"\""
    }
    set {

    }
}

however that would still allow access to the save as menu through the chevron. To suppress that, you need an NSWindowDelegate Docs

window(_:shouldPopUpDocumentPathMenu:) Asks the delegate whether the window displays the title pop-up menu in response to a Command-click or Control-click on its title.

Grimxn
  • 22,115
  • 10
  • 72
  • 85
  • Hi Grimxn, thank you for the answer, do you know if there is the possibility to hide also the popup menu in the title bar? (I edited the question to include this) – Cue May 15 '17 at 10:44
  • 2
    `shouldPopUpDocumentPathMenu:` suppressed the right click path popup, not the chevron rename/move popup. [How to disable NSDocument's window title popup](http://stackoverflow.com/a/40502619/4244136) – Willeke May 15 '17 at 15:05
0

Just add autosavesInPlace at true