-
-
Notifications
You must be signed in to change notification settings - Fork 193
File drag & drop support for Windows, Linux and WASM #275
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
File drag & drop support for Windows, Linux and WASM #275
Conversation
Miniquad can now handle dropped files on Windows and WASM. Since WASM cannot read the filesystem directly, the file bytes are read on Javascript side and sent to WASM.
looks like sokol has functions for getting dropped file paths and data, and the event itself does not have anything except the event type. That's probably better than having file path and data in the event. |
A single FILES_DROPPED event is sent when one or more files are dropped. File count, paths and bytes can be requested with functions `dropped_file_count`, `dropped_file_path` and `dropped_file_bytes`.
79fe982
to
a8f0e33
Compare
I changed the implementation so that sapp_event no longer carries the file path or bytes. Currently the drag & drop feature is always enabled. I've tested this with modified egui-miniquad demo on Windows, Linux and web. |
Wow, impressive work, thank you! I was thinking how to merge it for a little bit, sorry for delay :) I have some opinions on the API here, but, taking into account that all sapp-related stuff is being heavily refactored right now (yes, I still did not opened this PR...) - I would rather merge this as is and later on will change a few things. Hope this sounds good to you! Thanks again! |
Sounds good to me! I tried to mimic the existing api a bit when implementing this, but I did also expect I would need to make some changes after reviews. |
This is awesome! Adding some info: on Windows you can have > 260 character paths:
|
@nokola very good point. Currently this implementation assumes the path is at most 260 characters, but it would be easy to fix it. |
Miniquad can now handle dropped files on Windows, Linux and WASM.
A file path on Windows may be at most 260 characters long (16 bits each). On Mac it is 1024 bytes and on Linux it is 4096 bytes. Is it okay to have a 4096 bytes long array in sapp_event? If PathBuf is used, the event can no longer be
Copy
.In browsers you cannot read a file from the filesystem with a path, so the file bytes are read immediately in the file drop event. In native applications the file reading can be left to the client.