Simplify file_dialog example

This commit is contained in:
Emil Ernerfeldt 2022-04-30 15:49:22 +02:00
parent 8a2470b45e
commit c869f67066

View file

@ -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();
}
}
}