Vixen
dd8b0a81
csharp
public sealed class DropEvent

Something dragged in from outside the application and let go over a window.

Read the guide page for this →

Remarks

A file from Finder or Explorer, or a selection dragged out of another application. The operating system produces it, the platform layer forwards it, and it is hit-tested and bubbles exactly as a WheelEvent does — so a drop over a list inside a page reaches the list first and the page only if the list did not handle it.

Both representations are on the event and reachable as a DataObject. An OS drag-in cannot negotiate: the source is another process, the flavours were decided before this application was involved, and what arrives is a path or a string — so Files and Text are the honest shape for it and stay. ⚠ Data is materialised from them on demand rather than being a second thing a producer has to fill in, which is what lets one on:drop handler read a file dragged out of Finder and a row dragged out of a list in the same line of code.

A five-file drop is one event with five Files. The platforms do not hand it over that way — SDL 2 posts an SDL_DROPFILE per path with no coordinates, and the browser posts one per name — so the grouping is reconstructed from the brackets SDL puts round a run (SDL_DROPBEGIN/SDL_DROPCOMPLETE, mirrored on the web) and coalesced in PlatformInput. ⚠ Until that landed a handler that created a document per drop created five for one gesture, and it was invisible because five windows is what a user who dragged five files half expects.

⚠ A single-file drop from a backend with no brackets is still one event with one file, and that is the arrangement rather than an accident. The coalescing only ever starts when a group is opened, so a platform that cannot bracket loses nothing — which is the opposite of the failure a delivery deferred to DropComplete unconditionally would have had, where a backend that never sends one delivers no drops at all.

⚠ Not routed to a captured element. Everything else positional consults UiDocument.Captured first, because a pointer with capture belongs to the element that took it. A drag from another application never pressed a button in this one, so there is nothing it could have captured, and honouring a stale capture would deliver a file to whatever was last being dragged inside the window.

Fields and properties (8)

  • public float X

    Where it was dropped, in the surface's space.

  • public float Y

    Ditto.

  • public IReadOnlyList<string> Files

    The native paths that were dropped, empty if this was text.

  • public string? Text

    The text that was dropped, or if this was a file.

  • public TimeSpan Timestamp

    When, on the same clock as the rest.

  • public DataObject Data

    What was dropped, as formats a handler can ask for by name.

  • public UiElement? DragSource

    The element the drag started on, or if it came from outside.

  • public DropEffect Effect

    What the target said it would do with it while the drag was over it.

Used by (15)

  • HierarchyHelloUi
  • InspectorHelloUi
  • BuildContextVixen.Ui
  • CompositionTestsVixen.Ui.Tests
  • DropMarkupTestsVixen.Ui.Controls.Tests
  • DropRoutingTestsVixen.Platform.Ui.Tests
  • DropSheetVixen.Ui.Controls.Tests
  • DropTestsVixen.Ui.Tests
  • DroppedVixen.Ui.Tests
  • InAppDragTestsVixen.Ui.Tests
  • KeyboardDragTestsVixen.Ui.Tests
  • PlatformInputVixen.Platform.Ui
  • UiDocumentVixen.Ui
  • BrowserFileDropTestsVixen.Editor.App.Tests
  • ProjectBrowserVixen.Editor.App