Skip to content

Implement basic drag and drop APIs#547

Draft
stackotter wants to merge 2 commits intomainfrom
stackotter/fix_546
Draft

Implement basic drag and drop APIs#547
stackotter wants to merge 2 commits intomainfrom
stackotter/fix_546

Conversation

@stackotter
Copy link
Copy Markdown
Collaborator

@stackotter stackotter commented May 4, 2026

This PR introduces basic versions of SwiftUI's Transferrable-based drag and drop APIs. A proper Transferrable implementation is left for a future PR, as it would be rather involved. For now we're using a simple TransferrableData struct that caries data (bytes) along with a content type.

This resolves #546

Remaining tasks

  • Include a comprehensive set of built-in file types. I'm still trying to figure out the best shape for ContentType, but I think I'm getting close to a good design. I think we can automatically generate our file type declarations from macOS's UTType database (see the uttype CLI and the UniformTypeIdentifier's library)
  • Actually listen to file types during transfers
  • Check underlying file types of fileURL's? fileURL transfers are what you get when dragging from the system file explorer usually, but if applications have to manually open the files and determine their content type to filter out invalid drops, then that's not very ergonomic. If an application requests 'ContentType.png' and the dragged item is a fileURL to a PNG, then we should convert the dragged item to in-memory PNG content by reading the file into memory.
  • Allow applications to not care about fileURL content when importing data from a drop operation. If the application requests the dragged item's data we should just read the file on the application's behalf, if the file exists.
  • Support WinUIBackend
  • Support GtkBackend
  • Support UIKitBackend

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drag and drop between applications

1 participant