Instance Method

handleClose(_:)

Handles the close AppleScript command by attempting to close the window (and its associated document, if any).

Declaration

func handleClose(_ command: NSCloseCommand) -> Any?

Discussion

Extracts close command arguments from the command object and uses them to determine how to close the associated document—specifically, whether to ignore unsaved changes, save changes automatically, or ask the user and to identify the file in which to save the document (by default, the file that was opened or previously saved to, or an “untitled” name if the file has never been saved).

If there is a corresponding document and the window is the main window of the document, it forwards the close command to the corresponding document; otherwise, the window sends itself a performClose message, if it has a close box. This may have been handled differently in versions of macOS prior to version 10.3.

See Also

Handling Script Commands

func handlePrint(NSScriptCommand) -> Any?

Handles the print AppleScript command by attempting to print the contents of the window (or its associated document, if any).

func handleSave(NSScriptCommand) -> Any?

Handles the save AppleScript command by attempting to save the window (and its associated document, if any).