public interface IRunicFileDropTarget A Window's root ViewModel that receives the files the user drops onto the Window, with their real paths.
Remarks
Implement it on the ViewModel a Window opens with, and open the dropped files from the paths: public sealed partial class EditorViewModel : ObservableObject, IRunicFileDropTarget
{
public async ValueTask OnFilesDroppedAsync(RunicFileDrop drop, CancellationToken cancellationToken)
{
foreach (var file in drop.Files.Where(static file => !file.IsDirectory))
await OpenAsync(file.Path, cancellationToken);
}
} The host calls it in the ViewModel's model turn, as a command runs, once for each drop, in drop order. The token is cancelled when the Window closes. A failure is logged (event 1054, WindowFileDropFailed) and the Window stays open.
The paths come from the native window, never from the page: Runic Desktop's embedded window on Windows, macOS and Linux (GTK 3 and GTK 4) and the WPF child web View deliver drops. CS-WebUI and an installed browser have no native window that could report them; the page there only gets HTML5 File objects without paths. The page still receives its own dragenter, dragover and drop events, so it can highlight a drop target; dropping a file never navigates the Window away. A nested View that should receive drops on its own area marks its element with data-runic-drop-target; the root ViewModel routes the drop by RunicFileDrop.Target.
Methods
OnFilesDroppedAsync
ValueTask OnFilesDroppedAsync(RunicFileDrop drop, CancellationToken cancellationToken) Receives one drop of files onto the Window.
Parameters
dropThe dropped files and the page's routing label.
cancellationTokenCancelled when the Window closes.
Returns
A task that completes when the drop has been handled.