Simplify file_dialog example
This commit is contained in:
parent
8a2470b45e
commit
c869f67066
1 changed files with 32 additions and 34 deletions
|
@ -60,15 +60,19 @@ impl eframe::App for MyApp {
|
|||
}
|
||||
});
|
||||
|
||||
self.detect_files_being_dropped(ctx);
|
||||
preview_files_being_dropped(ctx);
|
||||
|
||||
// Collect dropped files:
|
||||
if !ctx.input().raw.dropped_files.is_empty() {
|
||||
self.dropped_files = ctx.input().raw.dropped_files.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MyApp {
|
||||
fn detect_files_being_dropped(&mut self, ctx: &egui::Context) {
|
||||
/// Preview hovering files:
|
||||
fn preview_files_being_dropped(ctx: &egui::Context) {
|
||||
use egui::*;
|
||||
|
||||
// Preview hovering files:
|
||||
if !ctx.input().raw.hovered_files.is_empty() {
|
||||
let mut text = "Dropping files:\n".to_owned();
|
||||
for file in &ctx.input().raw.hovered_files {
|
||||
|
@ -94,10 +98,4 @@ impl MyApp {
|
|||
Color32::WHITE,
|
||||
);
|
||||
}
|
||||
|
||||
// Collect dropped files:
|
||||
if !ctx.input().raw.dropped_files.is_empty() {
|
||||
self.dropped_files = ctx.input().raw.dropped_files.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue