Cancel in the "save changes" dialogue doesn't cancel


#1

In the "Save changes" dialogue that appears when you close a document without saving the "Cancel" button doesn't cancel closing the document or quitting the application (as it should). Instead it seems to be the same as pressing "Don't save".


#2

Can you please say what version of Subform you are using and what operating system you are on?

I just fired up 8afa768 on OS X and after some digging I found a bug, but I'm not sure if it's the same one you are running into.
The one I found: When you use the hotkey to quit (Command+Q) and press cancel, it works as it should. But if you actually use the mouse and the application menu (Subform -> Quit Subform) then Subform actually quits when you select cancel.


#3

I first discovered it in the initial release, but I managed to get the latest release 8afa768 and the bug is still there. (I didn't know there were later ones first, and had trouble finding the latest release when I looked on the forum. Maybe add a pinned post on the front page with the latest release? Or a page somewhere with a release history in chronological order so it's clear which one is the latest?)

As you say it happens when you pick the Quit menu item, but also when you just close the document window. It seems like there are a couple of strange things about this. If you open two documents it doesn't work when closing the first document, but then works the first time you try to close the second. The dialogue also says "Do you want to save before quitting" even though you're just closing a document and not quitting, and the buttons are not in the standard order (Don't save, Cancel and Save). All in all, it looks like you're not using the standard components you get for free using a subclass of NSDocument and NSDocumentController to manage this type of thing, which I think will end up causing you a lot of bugs/inconsistencies and extra work/headaches.


#4

All of the releases are listed here, which is linked to from the welcome message

Thanks for the additional detail on the cancel/quit behavior.
I'm interpreting:

as meaning mouse clicking the red circle at the top-left of the OS X window.

That the behavior is affected by multiple documents is also helpful for me to know, thanks.

Re: the order of options, I looked at three programs (Inventor, Wordpad, and Mathematica) on Windows and copied the order they had: Save, Don't Save, Cancel.
However, it turns out that OS X renders the buttons from right-to-left, which is why they make no sense at all.
I've added a conditional so that on OS X they render in the platform proper order: Don't Save, Cancel, Save.

As for the dialog copy, you are right --- it should refer to the document, not the app.
I'll change it to "Do you want to save the changes made to this document?" on both platforms, which is close to how Wordpad and TextEdit phrase it.

Re: standard OS X components like NSDocumentController, you are right in that we can't use them directly because we are building Subform for both Mac and Windows.

I'll cut a new release once I track down:

  • dialog issues with multiple open documents
  • dialog issues when quitting via menubar
  • dialog issues when quitting via clicking window "x"

Thanks for your patience and for taking the time to write!


#5

The inconsistent "close" behavior between hotkeys, window clicks, menu clicks, and multiple documents stems from a bug in the framework that Subform uses to interface with the operating system.
I've reworked Subform to avoid this broken API and handle closing via a separate codepath.

I've tested the fix and confirmed that the close confirmation modal dialog appears when:

  • You quit Subform via Subform -> Quit Subform
  • You quit Subform via the Command-Q hotkey
  • You close the current document only by mouse-clicking the red circle at the top left corner of the window

This last case is straightforward, since your action refers to only a single document.
The first two cases are a bit trickier, since it's possible you might have multiple unsaved documents open at the same time.

At first I just raised the confirmation modal on every window that had unsaved changes.
However, the operating system automatically focuses a window when you raise a modal, and when you raise on every window at the same time, it's undefined which window will actually end up focused.
This could lead to a situation where someone might choose "Save / Don't save" on a different window than the one that they were just working on, which is hella trouble.

So, instead, when you request to quit Subform either via hotkey or menu:

  1. All windows that don't have unsaved changes will be closed immediately
  2. If any documents are left, you will be focused on one of them, and the confirmation modal will appear only on that window.

Two consequences of this decision are that:

  • You have to keep closing documents with unsaved changes one-by-one via mouse, menu, or Command-Q
  • If you try to quit Subform without any windows focused (e.g., by control-clicking on the Dock icon on OS X and choosing 'quit'), then only the documents without unsaved changes will close --- you will need to explicitly focus on a document with unsaved changes to close it.

I thought it best to make fully explicit the destructive action of closing documents that have unsaved changes.

The OS X behavior for multiple unsaved documents (at least, according to TextEdit) is a more complex, two-modal process.
I'll implement that for the enterprise edition.