Vixen
dd8b0a81
csharp
public static class DocumentClosePrompt

Save / Don't Save / Cancel, joined to the close request that asks it.

Read the guide page for this →

Remarks

⚠ Every piece of this existed and nothing joined them. CloseRequestEvent routes from the focus outwards and can be refused, IsDirty is the question, and DialogService's own ChooseAsync remarks name "Save / Don't Save / Cancel" as the shape it exists for. What no file in the repository did was put the three together, so every application that wanted the one modal every desktop application has wrote it itself — which is the defect this repository meets most often, one level up from a missing feature.

⚠ The document is found by walking, not by being handed over. FindHostedDocument answers with the nearest one above the element the request reached, which is what makes this right in an application with two panels holding two documents: the request is raised on the focused element, so the document that is asked about is the one the user was working in.

⚠ The retry re-enters this handler, and "Don't Save" leaves the document dirty. A prompt is answered frames later, so the only way to close afterwards is to ask again — and asking again runs this code again, against a document that is still dirty because discarding does not clean it. Without the latch below, choosing Don't Save reopens the prompt for ever and the application cannot be quit. Marking the document clean instead would be a lie told to every other consumer of the same signal.

Methods (1)

Used by (2)

  • ShellHelloUi
  • DocumentClosePromptTestsVixen.Ui.Controls.Tests