Closing documents

In former AS Studio there was a command line to show an alert giving the user a chance to save, not save or cancel before closing an edited document (in particular with table views)


In AS Studio:
set modified of document of window "main" to true

I searched for an equivalent command in ASOC but without success.

I found some pieces which I can’t put together:

  • (BOOL) hasEditedDocuments (in NSDocumentController)
  • (BOOL) isDocumentEdited (in NSDocument)
  • (void) canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: (in NSDocument)

The shouldCloseSelector shoult have the signature:

  • (void) document: (NSDocument *) doc shouldClose:(BOOL) shouldClose contextInfo:(void *) contextInfo

Heiner

I suspect that all you need is:

theDoc’s updateChangeCount_(current application’s NSChangeDone)

Shane, that is the magic word!

Now (I think) my app is completly done.

Thank you again for all your helps.

Heiner

PS: Here are the complete lines for this task:


property documentControllerClass : class "NSDocumentController"
	property mainWindow : missing value -- binding!
	
	-- in the particular handler:
	set theDoc to documentControllerClass's sharedDocumentController's documentForWindow_(mainWindow)
	theDoc's updateChangeCount_(current application's NSChangeDone)