Vixen
dd8b0a81
csharp
public sealed class DataObject

A payload offered in every representation its source can produce.

Read the guide page for this →

Remarks

The negotiation is the point. A drag source rarely knows what will be under the pointer when the button comes up. An asset row dragged out of a browser is a vixen.asset-id to a material slot, a path to a file field and its own name to a text box — the same drag, three answers — so the source offers all three and each target asks for the one it can use. That is NSPasteboard's model and the DOM's, and it is the half an OS drag-in cannot have, which is why DropEvent carries its two fixed representations as well.

⚠ Format names are IClipboard's vocabulary, values are not. Vixen.Platform.IClipboard.TryGetData is bytes, because a pasteboard is a boundary between processes and bytes are all that crosses it. Both ends of an in-app drag are objects in one heap, so serialising an AssetId to bytes so the panel next door can parse it back is cost with nothing bought. The names match so that the day a drag does leave the process, a source already offering Text needs no new vocabulary.

⚠ Ordered, and the order is the source's preference. Formats comes back in the order it was offered, so a target that can take several asks for them in turn and gets what the source would rather it had. A dictionary's own order would make that answer depend on hash codes.

Fields and properties (3)

  • public IReadOnlyList<string> Formats

    What it can be read as, best first.

  • public string? Text

    The text representation, or if it offers none.

  • public IReadOnlyList<string> Files

    The native paths it offers, empty if it offers none.

Methods (5)

  • public void Set(string format, object value)

    Offers one representation.

  • public void SetText(string text)

    Offers it as text.

  • public void SetFiles(IReadOnlyList<string> paths)

    Offers it as native paths.

  • public bool Has(string format)

    Whether it can be read in that format.

  • public bool TryGet<T>(string format, out T? value)

    Reads one representation.

Used by (12)

  • HierarchyHelloUi
  • InspectorHelloUi
  • DataObjectTestsVixen.Ui.Tests
  • DragOverEventVixen.Ui
  • DragSessionVixen.Ui
  • DropEventVixen.Ui
  • DropMarkupTestsVixen.Ui.Controls.Tests
  • DropSheetVixen.Ui.Controls.Tests
  • DroppedVixen.Ui.Tests
  • InAppDragTestsVixen.Ui.Tests
  • KeyboardDragTestsVixen.Ui.Tests
  • UiDocumentVixen.Ui