-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic file drag and drop support
- Loading branch information
1 parent
3b2c6ce
commit 3947907
Showing
6 changed files
with
99 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use bevy::prelude::*; | ||
|
||
#[derive(Default)] | ||
struct DroppedFileSystemState { | ||
dropped_filed_event_reader: EventReader<DroppedFile>, | ||
hovered_file_event_reader: EventReader<HoveredFile>, | ||
hovered_file_canceled_event_reader: EventReader<HoveredFileCancelled>, | ||
} | ||
|
||
fn main() { | ||
App::build() | ||
.add_plugins(DefaultPlugins) | ||
.add_system(dropped_file_system.system()) | ||
.run(); | ||
} | ||
|
||
fn dropped_file_system( | ||
mut state: Local<DroppedFileSystemState>, | ||
dropped_file_events: Res<Events<DroppedFile>>, | ||
hovered_file_events: Res<Events<HoveredFile>>, | ||
hovered_file_canceled_events: Res<Events<HoveredFileCancelled>>, | ||
) { | ||
for event in state.dropped_filed_event_reader.iter(&dropped_file_events) { | ||
println!("Dropped file{:?}", event); | ||
} | ||
|
||
for event in state.hovered_file_event_reader.iter(&hovered_file_events) { | ||
println!("Hovered file{:?}", event); | ||
} | ||
|
||
for event in state | ||
.hovered_file_canceled_event_reader | ||
.iter(&hovered_file_canceled_events) | ||
{ | ||
println!("Dropped file{:?}", event); | ||
} | ||
} |