-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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 basic file drag and drop support #1096
Conversation
crates/bevy_winit/src/lib.rs
Outdated
@@ -370,6 +400,7 @@ pub fn winit_runner(mut app: App) { | |||
); | |||
app.update(); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other matches are not separated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you're saying here sorry, could you explain please?
Could you clarify in the title that this is file drag and drop support? |
@DJMcNab Will do. I'll update the commit message as well. |
4f02ad8
to
3947907
Compare
I've tested on wasm, and this doesn't work unfortunently. But it looks like winit doesn't have it either https://github.com/rust-windowing/winit/blob/master/FEATURES.md#input-handling-1. |
crates/bevy_winit/src/lib.rs
Outdated
} | ||
WindowEvent::HoveredFile(path_buf) => { | ||
let mut hovered_file_events = | ||
app.resources.get_mut::<Events<HoveredFile>>().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should probably combine all drag and drop events into a single event. It seems like order of operations matters here (ex: when did the cancel happen relative to HoveredFile).
(not relevant to this pr, but there are a couple of other events here that we should revisit when it comes to combining/ordering, such as CursorLeft/CursorEntered)
52566de
to
6d26499
Compare
I took a stab at creating a simple plugin and resource to handle dropped files (and added it to `DefaultPlugins). The plugin gives you a I can't see the point of allowing direct access to |
For reference, I'm also attempting to add file drag and drop for wasm into winit rust-windowing/winit#1808. |
I was more talking about combining the drag and drop events into a single event stream to preserve ordering (see the changes I just pushed). I think the drag and drop plugin introduces a bit too much complexity for what it adds, so I reverted that in favor of the consolidated event. |
Just rebased on master / resolved conflicts. I think this is good to go! |
I fixed the path in the README and changed the system name in the example to something a bit clearer. |
Adds basic drag and drop support to bevy.
It simply exposes the relevant events already found in winit.
This has been tested on Linux, and because it simply wraps around the winit events, it should work on other systems just fine (hopefully!).
I still want to try wasm/web before merging. (Or someone else, I haven't played with wasm in rust or bevy much yet!)
Let me know if there's anything missing!