Vixen
feb85697
csharp
public static class DocumentCommands

The command ids a document answers, and the one call that makes an element answer them.

Read the guide page for this →

Remarks

⚠ Answered through the command route rather than by a service, which is the whole point of putting them here. An application with two documents open in two panels has two answers to ⌘S, and the right one is decided by where the focus is — the route already walks focus → parents → root and picks the nearest handler, so a panel that hosts a document registers these and nothing else has to know how many panels there are. A save routed to "the application's document" is the bug this shape does not have.

Fields and properties (3)

  • public const string Save

    Write the nearest document out.

  • public const string Revert

    Throw the nearest document's changes away.

  • public const string Close

    Ask whether the nearest document may be put down.

Methods (3)

  • public static void Install(UiElement element)

    Makes an element answer Save, Revert and Close for the document it hosts.

  • public static void Install(UiElement element, Action? revert)

    Makes an element answer the three ids for the document it hosts, reverting it the host's way.

  • public static bool HasUnsavedChanges(IEditableDocument document)

    Whether saving a document would write anything: its own edits, or a change from outside.

Used by (13)

  • ShellHelloUi
  • DerivedDirtyStateTestsVixen.Ui.Tests
  • DocumentClosePromptVixen.Ui.Controls
  • DocumentClosePromptTestsVixen.Ui.Controls.Tests
  • EditableDocumentTestsVixen.Ui.Tests
  • ShortcutDispatchTestsVixen.Ui.Controls.Tests
  • UiWindowTitleVixen.Ui
  • DocumentChordTestsVixen.Editor.App.Tests
  • EditorApplicationVixen.Editor.App
  • EditorShellVixen.Editor.Ui
  • EditorWorkspaceVixen.Editor.Ui
  • SceneFileQuestionsVixen.Editor.App
  • WorkspaceModuleVixen.Editor.App