简体   繁体   中英

NSWindow "Edited" not shown

I have an application, which is primarily for presenting documents but can under certain circumstances also change the presented document. That's why my app isn't a real document based app.

Nevertheless I want to display the "— Edited" additive to my window title, when the document has been edited and the changes weren't saved yet.

Therefore I have to methods in my AppDelegate

@objc func didEditDocument(_ notification: Notification) {
    myMainWindow.windowController?.setDocumentEdited(true)
}


@objc func didSaveDocument(_ notification: Notification) {
    myMainWindow.windowController?.setDocumentEdited(false)
}

I was expecting my window title to change from MyWindow to MyWindow — Edited after calling .setDocumentEdited(true) , but that didn't happen. But the dot in the red close button changes. What am I doing wrong?

What am I doing wrong

Nothing. When you rejected the NSDocument architecture, you rejected the automatic "Edited" title change along with a lot of other automatic crunchy goodness. Nothing wrong with that, but then you can't complain when the crunchy goodness is missing. If you want the title changed, you'll have to change it yourself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM