Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file drag and drop support on wasm #1808

Closed

Conversation

ShadowMitia
Copy link

@ShadowMitia ShadowMitia commented Dec 25, 2020

  • Tested on all platforms changed
  • Compilation warnings were addressed
  • cargo fmt has been run on this branch
  • cargo doc builds successfully
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

Hello!

I'm trying to add drag and drop for wasm.
I don't know if I should open an issue for this as well, let me know if I should.

I've arrived to a sort of PoC for it on this branch but I have several issues.

If you want to try out this branch, just run the "web" example and watch for any of the DroppedFile, HoveredFile, HoveredFileCanceled in the WindowEvent.

First of all I seem to have a bug for HoveredFiles because when getting the files in the underlying objects, the file list is always 0. I need to investigate that some more.

Currently the DroppedFile, HoveredFile only return the filenames (not the full path), mainly because of HTML5 security reasons. And I don't really know how to move from here.

I see two ways to solve this :

  • Change DroppedFile, HoveredFile for wasm, which return some new type which will be the file data directly (or allows for easy access, without having to deal with HTML stuff).
  • Keep the interface, but have another object that allows to access the files, and use the filename in DroppedFile, HoveredFile to gain access to the correct file. This sounds more reaosnable, but I have currrently no idea how to do this.

I'll look into this some more, but if anyone has any ideas or feedbacks I would appreciate it!

Related issue : #720

@ShadowMitia ShadowMitia force-pushed the filedraganddrop-wasm branch from 3690eba to ae2f242 Compare January 1, 2021 14:25
@ShadowMitia
Copy link
Author

I've arrived to a POC. I've thought about it and I realised that this needs to be as simple as possible, and give the user the choice of managing what to do with the file, just like with the regular interface. It still needs a different interface in wasm, because we're dealing with the file directly. So I've chosen to return a web_sys::File directly, and then have the user manage the event however they seem. I've got an example running in the web.rs example.

@daxpedda
Copy link
Member

daxpedda commented Jun 2, 2023

I'm going to close this as it's pretty old and needs to be done from scratch anyway.

Would love to see support for this, happy to review a new PR!

@daxpedda daxpedda closed this Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants