[Openmcl-devel] suppressing "... save the changes ...?"
gb at clozure.com
Fri Feb 24 06:54:32 UTC 2012
Cocoa will try to save the document associated with a window when the window
is about to close if:
a) there is a document associated with a window. The right way to determine
this is to obtain the window's window controller and ask it for the associated
document,, as in:
(let* ((document (#/document (#/windowController theWindow))))
though it happens to work to call an apparently undocumented #/document
method on an NSWindow object (and we've had code in the IDE that's done that.)
b) that document's #/isDocumentEdited method returns true.
The IDE uses a different class of NSDocument for listener windows than
it does for editor windows, and that document class's
#/isDocumentEdited method returns false. (The #/setDocumentEdited:
methods on the related window and window-controller classes are no-ops,
but that may be overkill.) A listener window's close box never turns dark
red and closing one doesn't result in the dialog that you're trying to avoid.
If you don't want to create subclasses, you might consider redefining
the #/setDocumentEdited: method on the HEMLOCK-FRAME class in
ccl:cocoa-ide;cocoa-editor.lisp. The current implementation tries to
determine whether or not the document's changed status is changing and
arranges to update the modeline before calling the next method if so, and
if you can determine that the window/buffer/whatever belongs to one of
your scratch windows you might want to make that method do nothing.
(It might also be useful to have that method print something whenever it's
called; that output would go to the AltConsole window and there may be a lot
of it. Calling (#/setDocumentEdited: theWindow #$NO) should convince Cocoa
that nothing needs to be saved, but something else may be saying the exact
On Thu, 23 Feb 2012, Arthur Cater wrote:
> I've a problem with some code I've recently contributed. It creates Hemlock windows
> and streams for writing to them (and provides a format directive /clickable/ which is
> not the issue here).
> The windows have an annoying feature, which is that when I close one manually
> I get asked "Do you want to save the changes ...". For some windows at least,
> I'd like to regard them as scratch windows that should just go away when they are
> told to. I tried (in a private version, not in the version you might find in contribs)
> a number of things in a specialised #/windowShouldClose method,
> but have learned that the question is asked before that method is invoked.
> I now (in private) arrange - and this still does not work! - that whenever I write to the stream
> I do so inside GUI::EXECUTE-IN-GUI and also there do
> (#/updateChangeCount: <theDocument> #$NSChangeCleared)
> (hi::%set-buffer-modified <theBuffer> nil)
> (#/setDocumentEdited: <theWindow> #$NO)
> Can anyone please suggest a workable way to get a Hemlock window to just die quietly?
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
More information about the Openmcl-devel