diff --git a/CHANGELOG.md b/CHANGELOG.md index d9dddbe6..6e4f833e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # egui-file-dialog changelog +## Unreleased +### 🚨 Breaking Changes + +- Removed deprecated methods `FileDialog::select_directory`, `FileDialog::select_file`, `FileDialog::select_multiple`, `FileDialog::overwrite_config`, `FileDialog::selected`, `FileDialog::take_selected`, `FileDialog::take_selected_multiple` [#229](https://github.com/fluxxcode/egui-file-dialog/pull/229) +- Renamed `DialogMode`'s: `SelectFile` -> `PickFile`, `SelectDirectory` -> `PickDirectory`, `SelectMultiple` -> `PickMultiple` [#229](https://github.com/fluxxcode/egui-file-dialog/pull/229) +- Renamed `DialogState`'s: `Selected` -> `Picked`, `SelectedMultiple` -> `PickedMultiple` [#229](https://github.com/fluxxcode/egui-file-dialog/pull/229) +- Renamed `active_entry` -> `selected_entry` [#229](https://github.com/fluxxcode/egui-file-dialog/pull/229) +- Renamed `active_selected_entries` -> `selected_entries` [#229](https://github.com/fluxxcode/egui-file-dialog/pull/229) + ## 2024-12-17 - v0.8.0 - egui update, custom right panel and more ### 🚨 Breaking Changes diff --git a/examples/custom_right_panel.rs b/examples/custom_right_panel.rs index 8eddd57e..ff772a5b 100644 --- a/examples/custom_right_panel.rs +++ b/examples/custom_right_panel.rs @@ -39,25 +39,25 @@ impl eframe::App for MyApp { self.file_dialog .update_with_right_panel_ui(ctx, &mut |ui, dia| { - if dia.mode() == DialogMode::SelectMultiple { + if dia.mode() == DialogMode::PickMultiple { ui.heading("Selected items"); ui.separator(); egui::ScrollArea::vertical() .max_height(ui.available_height()) .show(ui, |ui| { - for item in dia.active_selected_entries() { + for item in dia.selected_entries() { ui.small(format!("{item:#?}")); ui.separator(); } }); } else { ui.heading("Active item"); - ui.small(format!("{:#?}", dia.active_entry())); + ui.small(format!("{:#?}", dia.selected_entry())); } }); match self.file_dialog.mode() { - DialogMode::SelectMultiple => { + DialogMode::PickMultiple => { if let Some(items) = self.file_dialog.take_picked_multiple() { self.picked_items = Some(items); } diff --git a/examples/multiple_actions.rs b/examples/multiple_actions.rs index c8c44331..71cb2573 100644 --- a/examples/multiple_actions.rs +++ b/examples/multiple_actions.rs @@ -27,13 +27,13 @@ impl eframe::App for MyApp { if ui.button("Pick file a").clicked() { let _ = self .file_dialog - .open(DialogMode::SelectFile, true, Some("pick_a")); + .open(DialogMode::PickFile, true, Some("pick_a")); } if ui.button("Pick file b").clicked() { let _ = self .file_dialog - .open(DialogMode::SelectFile, true, Some("pick_b")); + .open(DialogMode::PickFile, true, Some("pick_b")); } ui.label(format!("Pick file a: {:?}", self.picked_file_a)); diff --git a/examples/sandbox.rs b/examples/sandbox.rs index ac29bfdf..6f366931 100644 --- a/examples/sandbox.rs +++ b/examples/sandbox.rs @@ -102,10 +102,10 @@ impl eframe::App for MyApp { if let Some(path) = self.file_dialog.take_picked() { match self.file_dialog.mode() { - DialogMode::SelectDirectory => self.picked_directory = Some(path), - DialogMode::SelectFile => self.picked_file = Some(path), + DialogMode::PickDirectory => self.picked_directory = Some(path), + DialogMode::PickFile => self.picked_file = Some(path), DialogMode::SaveFile => self.saved_file = Some(path), - DialogMode::SelectMultiple => {} + DialogMode::PickMultiple => {} } } diff --git a/src/file_dialog.rs b/src/file_dialog.rs index c5ca2d97..60a23cf9 100644 --- a/src/file_dialog.rs +++ b/src/file_dialog.rs @@ -16,13 +16,13 @@ use std::path::{Path, PathBuf}; #[derive(Debug, PartialEq, Eq, Clone, Copy)] pub enum DialogMode { /// When the dialog is currently used to select a single file. - SelectFile, + PickFile, /// When the dialog is currently used to select a single directory. - SelectDirectory, + PickDirectory, /// When the dialog is currently used to select multiple files and directories. - SelectMultiple, + PickMultiple, /// When the dialog is currently used to save a file. SaveFile, @@ -38,10 +38,10 @@ pub enum DialogState { Closed, /// The user has selected a folder or file or specified a destination path for saving a file. - Selected(PathBuf), + Picked(PathBuf), /// The user has finished selecting multiple files and folders. - SelectedMultiple(Vec), + PickedMultiple(Vec), /// The user cancelled the dialog and didn't select anything. Cancelled, @@ -62,12 +62,12 @@ pub enum DialogState { /// /// impl MyApp { /// fn update(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) { -/// if ui.button("Select a file").clicked() { -/// self.file_dialog.select_file(); +/// if ui.button("Pick a file").clicked() { +/// self.file_dialog.pick_file(); /// } /// -/// if let Some(path) = self.file_dialog.update(ctx).selected() { -/// println!("Selected file: {:?}", path); +/// if let Some(path) = self.file_dialog.update(ctx).picked() { +/// println!("Picked file: {:?}", path); /// } /// } /// } @@ -196,7 +196,7 @@ impl FileDialog { modals: Vec::new(), - mode: DialogMode::SelectDirectory, + mode: DialogMode::PickDirectory, state: DialogState::Closed, show_files: true, operation_id: None, @@ -275,28 +275,28 @@ impl FileDialog { /// struct MyApp { /// file_dialog: FileDialog, /// - /// selected_file_a: Option, - /// selected_file_b: Option, + /// picked_file_a: Option, + /// picked_file_b: Option, /// } /// /// impl MyApp { /// fn update(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) { - /// if ui.button("Select file a").clicked() { - /// let _ = self.file_dialog.open(DialogMode::SelectFile, true, Some("select_a")); + /// if ui.button("Pick file a").clicked() { + /// let _ = self.file_dialog.open(DialogMode::PickFile, true, Some("pick_a")); /// } /// - /// if ui.button("Select file b").clicked() { - /// let _ = self.file_dialog.open(DialogMode::SelectFile, true, Some("select_b")); + /// if ui.button("Pick file b").clicked() { + /// let _ = self.file_dialog.open(DialogMode::PickFile, true, Some("pick_b")); /// } /// /// self.file_dialog.update(ctx); /// - /// if let Some(path) = self.file_dialog.selected() { - /// if self.file_dialog.operation_id() == Some("select_a") { - /// self.selected_file_a = Some(path.to_path_buf()); + /// if let Some(path) = self.file_dialog.picked() { + /// if self.file_dialog.operation_id() == Some("pick_a") { + /// self.picked_file_a = Some(path.to_path_buf()); /// } - /// if self.file_dialog.operation_id() == Some("select_b") { - /// self.selected_file_b = Some(path.to_path_buf()); + /// if self.file_dialog.operation_id() == Some("pick_b") { + /// self.picked_file_b = Some(path.to_path_buf()); /// } /// } /// } @@ -310,7 +310,7 @@ impl FileDialog { ) -> io::Result<()> { self.reset(); - if mode == DialogMode::SelectFile { + if mode == DialogMode::PickFile { show_files = true; } @@ -352,23 +352,7 @@ impl FileDialog { /// /// The function ignores the result of the initial directory loading operation. pub fn pick_directory(&mut self) { - let _ = self.open(DialogMode::SelectDirectory, false, None); - } - - /// Shortcut function to open the file dialog to prompt the user to select a directory. - /// If used, no files in the directories will be shown to the user. - /// Use the `open()` method instead, if you still want to display files to the user. - /// This function resets the file dialog. Configuration variables such as - /// `initial_directory` are retained. - /// - /// The function ignores the result of the initial directory loading operation. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::pick_directory` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn select_directory(&mut self) { - self.pick_directory(); + let _ = self.open(DialogMode::PickDirectory, false, None); } /// Shortcut function to open the file dialog to prompt the user to pick a file. @@ -377,21 +361,7 @@ impl FileDialog { /// /// The function ignores the result of the initial directory loading operation. pub fn pick_file(&mut self) { - let _ = self.open(DialogMode::SelectFile, true, None); - } - - /// Shortcut function to open the file dialog to prompt the user to select a file. - /// This function resets the file dialog. Configuration variables such as - /// `initial_directory` are retained. - /// - /// The function ignores the result of the initial directory loading operation. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::pick_file` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn select_file(&mut self) { - self.pick_file(); + let _ = self.open(DialogMode::PickFile, true, None); } /// Shortcut function to open the file dialog to prompt the user to pick multiple @@ -401,22 +371,7 @@ impl FileDialog { /// /// The function ignores the result of the initial directory loading operation. pub fn pick_multiple(&mut self) { - let _ = self.open(DialogMode::SelectMultiple, true, None); - } - - /// Shortcut function to open the file dialog to prompt the user to select multiple - /// files and folders. - /// This function resets the file dialog. Configuration variables such as `initial_directory` - /// are retained. - /// - /// The function ignores the result of the initial directory loading operation. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::pick_multiple` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn select_multiple(&mut self) { - self.pick_multiple(); + let _ = self.open(DialogMode::PickMultiple, true, None); } /// Shortcut function to open the file dialog to prompt the user to save a file. @@ -480,72 +435,6 @@ impl FileDialog { // ------------------------------------------------- // Setter: - /// Overwrites the configuration of the file dialog. - /// - /// This is useful when you want to configure multiple `FileDialog` objects with the - /// same configuration. If you only want to configure a single object, - /// it's probably easier to use the setter methods like `FileDialog::initial_directory` - /// or `FileDialog::default_pos`. - /// - /// If you want to create a new `FileDialog` object with a config, - /// you probably want to use `FileDialog::with_config`. - /// - /// NOTE: Any configuration that was set before `FileDialog::overwrite_config` - /// will be overwritten! \ - /// This means, for example, that the following code is invalid: - /// ``` - /// pub use egui_file_dialog::{FileDialog, FileDialogConfig}; - /// - /// fn create_file_dialog() -> FileDialog { - /// FileDialog::new() - /// .title("Hello world") - /// // This will overwrite `.title("Hello world")`! - /// .overwrite_config(FileDialogConfig::default()) - /// } - /// - /// ``` - /// - /// # Examples - /// - /// ``` - /// use egui_file_dialog::{FileDialog, FileDialogConfig}; - /// - /// struct MyApp { - /// file_dialog_a: FileDialog, - /// file_dialog_b: FileDialog, - /// } - /// - /// impl MyApp { - /// pub fn new() -> Self { - /// let config = FileDialogConfig { - /// default_size: egui::Vec2::new(500.0, 500.0), - /// resizable: false, - /// movable: false, - /// ..Default::default() - /// }; - /// - /// Self { - /// file_dialog_a: FileDialog::new() - /// .overwrite_config(config.clone()) - /// .title("File Dialog A") - /// .id("fd_a"), - /// - /// file_dialog_b: FileDialog::new() - /// .overwrite_config(config) - /// .title("File Dialog B") - /// .id("fd_b"), - /// } - /// } - /// } - /// ``` - #[deprecated( - since = "0.6.0", - note = "use `FileDialog::with_config` and `FileDialog::config_mut` instead" - )] - pub fn overwrite_config(mut self, config: FileDialogConfig) -> Self { - self.config = config; - self - } /// Mutably borrow internal `config`. pub fn config_mut(&mut self) -> &mut FileDialogConfig { @@ -1034,24 +923,11 @@ impl FileDialog { /// None is returned when the user has not yet selected an item. pub fn picked(&self) -> Option<&Path> { match &self.state { - DialogState::Selected(path) => Some(path), + DialogState::Picked(path) => Some(path), _ => None, } } - /// Returns the directory or file that the user selected, or the target file - /// if the dialog is in `DialogMode::SaveFile` mode. - /// - /// None is returned when the user has not yet selected an item. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::picked` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn selected(&self) -> Option<&Path> { - self.picked() - } - /// Returns the directory or file that the user picked, or the target file /// if the dialog is in `DialogMode::SaveFile` mode. /// Unlike `FileDialog::picked`, this method returns the picked path only once and @@ -1060,7 +936,7 @@ impl FileDialog { /// None is returned when the user has not yet picked an item. pub fn take_picked(&mut self) -> Option { match &mut self.state { - DialogState::Selected(path) => { + DialogState::Picked(path) => { let path = std::mem::take(path); self.state = DialogState::Closed; Some(path) @@ -1069,47 +945,19 @@ impl FileDialog { } } - /// Returns the directory or file that the user selected, or the target file - /// if the dialog is in `DialogMode::SaveFile` mode. - /// Unlike `FileDialog::selected`, this method returns the selected path only once and - /// sets the dialog's state to `DialogState::Closed`. - /// - /// None is returned when the user has not yet selected an item. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::take_picked` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn take_selected(&mut self) -> Option { - self.take_picked() - } - /// Returns a list of the files and folders the user picked, when the dialog is in /// `DialogMode::PickMultiple` mode. /// /// None is returned when the user has not yet picked an item. pub fn picked_multiple(&self) -> Option> { match &self.state { - DialogState::SelectedMultiple(items) => { + DialogState::PickedMultiple(items) => { Some(items.iter().map(std::path::PathBuf::as_path).collect()) } _ => None, } } - /// Returns a list of the files and folders the user selected, when the dialog is in - /// `DialogMode::SelectMultiple` mode. - /// - /// None is returned when the user has not yet selected an item. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::picked_multiple` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn selected_multiple(&self) -> Option> { - self.picked_multiple() - } - /// Returns a list of the files and folders the user picked, when the dialog is in /// `DialogMode::PickMultiple` mode. /// Unlike `FileDialog::picked_multiple`, this method returns the picked paths only once @@ -1118,7 +966,7 @@ impl FileDialog { /// None is returned when the user has not yet picked an item. pub fn take_picked_multiple(&mut self) -> Option> { match &mut self.state { - DialogState::SelectedMultiple(items) => { + DialogState::PickedMultiple(items) => { let items = std::mem::take(items); self.state = DialogState::Closed; Some(items) @@ -1127,21 +975,6 @@ impl FileDialog { } } - /// Returns a list of the files and folders the user selected, when the dialog is in - /// `DialogMode::SelectMultiple` mode. - /// Unlike `FileDialog::selected_multiple`, this method returns the selected paths only once - /// and sets the dialog's state to `DialogState::Closed`. - /// - /// None is returned when the user has not yet selected an item. - #[deprecated( - since = "0.8.0", - note = "renamed to `FileDialog::take_picked_multiple` for more consistent naming. \ - Will be removed in a future release, most likely 0.9.0." - )] - pub fn take_selected_multiple(&mut self) -> Option> { - self.take_picked_multiple() - } - /// Returns the currently active directory entry. /// /// This is either the currently highlighted entry, or the currently active directory @@ -1149,7 +982,7 @@ impl FileDialog { /// /// For the [`DialogMode::SelectMultiple`] counterpart, /// see [`FileDialog::active_selected_entries`]. - pub const fn active_entry(&self) -> Option<&DirectoryEntry> { + pub const fn selected_entry(&self) -> Option<&DirectoryEntry> { self.selected_item.as_ref() } @@ -1158,7 +991,7 @@ impl FileDialog { /// For the counterpart in single selection modes, see [`FileDialog::active_entry`]. /// /// [`SelectMultiple`]: DialogMode::SelectMultiple - pub fn active_selected_entries(&self) -> impl Iterator { + pub fn selected_entries(&self) -> impl Iterator { self.get_dir_content_filtered_iter().filter(|p| p.selected) } @@ -1373,9 +1206,9 @@ impl FileDialog { match &self.config.title { Some(title) => title, None => match &self.mode { - DialogMode::SelectDirectory => &self.config.labels.title_select_directory, - DialogMode::SelectFile => &self.config.labels.title_select_file, - DialogMode::SelectMultiple => &self.config.labels.title_select_multiple, + DialogMode::PickDirectory => &self.config.labels.title_select_directory, + DialogMode::PickFile => &self.config.labels.title_select_file, + DialogMode::PickMultiple => &self.config.labels.title_select_multiple, DialogMode::SaveFile => &self.config.labels.title_save_file, }, } @@ -1927,7 +1760,7 @@ impl FileDialog { // Calculate the width of the action buttons let label_submit_width = match self.mode { - DialogMode::SelectDirectory | DialogMode::SelectFile | DialogMode::SelectMultiple => { + DialogMode::PickDirectory | DialogMode::PickFile | DialogMode::PickMultiple => { Self::calc_text_width(ui, &self.config.labels.open_button) } DialogMode::SaveFile => Self::calc_text_width(ui, &self.config.labels.save_button), @@ -1958,16 +1791,16 @@ impl FileDialog { let item_spacing = ui.style().spacing.item_spacing; let render_filter_selection = !self.config.file_filters.is_empty() - && (self.mode == DialogMode::SelectFile || self.mode == DialogMode::SelectMultiple); + && (self.mode == DialogMode::PickFile || self.mode == DialogMode::PickMultiple); let filter_selection_width = button_size.x.mul_add(2.0, item_spacing.x); let mut filter_selection_separate_line = false; ui.horizontal(|ui| { match &self.mode { - DialogMode::SelectDirectory => ui.label(&self.config.labels.selected_directory), - DialogMode::SelectFile => ui.label(&self.config.labels.selected_file), - DialogMode::SelectMultiple => ui.label(&self.config.labels.selected_items), + DialogMode::PickDirectory => ui.label(&self.config.labels.selected_directory), + DialogMode::PickFile => ui.label(&self.config.labels.selected_file), + DialogMode::PickMultiple => ui.label(&self.config.labels.selected_items), DialogMode::SaveFile => ui.label(&self.config.labels.file_name), }; @@ -1983,9 +1816,7 @@ impl FileDialog { } match &self.mode { - DialogMode::SelectDirectory - | DialogMode::SelectFile - | DialogMode::SelectMultiple => { + DialogMode::PickDirectory | DialogMode::PickFile | DialogMode::PickMultiple => { use egui::containers::scroll_area::ScrollBarVisibility; let text = self.get_selection_preview_text(); @@ -2035,11 +1866,11 @@ impl FileDialog { fn get_selection_preview_text(&self) -> String { if self.is_selection_valid() { match &self.mode { - DialogMode::SelectDirectory | DialogMode::SelectFile => self + DialogMode::PickDirectory | DialogMode::PickFile => self .selected_item .as_ref() .map_or_else(String::new, |item| item.file_name().to_string()), - DialogMode::SelectMultiple => { + DialogMode::PickMultiple => { let mut result = String::new(); for (i, item) in self @@ -2110,9 +1941,9 @@ impl FileDialog { fn ui_update_action_buttons(&mut self, ui: &mut egui::Ui, button_size: egui::Vec2) { ui.with_layout(egui::Layout::right_to_left(egui::Align::Min), |ui| { let label = match &self.mode { - DialogMode::SelectDirectory - | DialogMode::SelectFile - | DialogMode::SelectMultiple => self.config.labels.open_button.as_str(), + DialogMode::PickDirectory | DialogMode::PickFile | DialogMode::PickMultiple => { + self.config.labels.open_button.as_str() + } DialogMode::SaveFile => self.config.labels.save_button.as_str(), }; @@ -2178,7 +2009,7 @@ impl FileDialog { true } DirectoryContentState::Finished => { - if self.mode == DialogMode::SelectDirectory { + if self.mode == DialogMode::PickDirectory { if let Some(dir) = self.current_directory() { let mut dir_entry = DirectoryEntry::from_path(&self.config, dir); self.select_item(&mut dir_entry); @@ -2344,14 +2175,14 @@ impl FileDialog { self.select_item(item); // Reset the multi selection except the now primary selected item - if self.mode == DialogMode::SelectMultiple { + if self.mode == DialogMode::PickMultiple { *reset_multi_selection = true; } } // The user wants to select or unselect the item as part of a // multi selection - if self.mode == DialogMode::SelectMultiple + if self.mode == DialogMode::PickMultiple && re.clicked() && ui.input(|i| i.modifiers.command) { @@ -2372,7 +2203,7 @@ impl FileDialog { // The user wants to select every item between the last selected item // and the current item - if self.mode == DialogMode::SelectMultiple + if self.mode == DialogMode::PickMultiple && re.clicked() && ui.input(|i| i.modifiers.shift_only()) { @@ -2693,7 +2524,7 @@ impl FileDialog { } if FileDialogKeyBindings::any_pressed(ctx, &keybindings.select_all, true) - && self.mode == DialogMode::SelectMultiple + && self.mode == DialogMode::PickMultiple { for item in self.directory_content.filtered_iter_mut(&self.search_value) { item.selected = true; @@ -2841,7 +2672,7 @@ impl FileDialog { fn exec_modal_action(&mut self, action: ModalAction) { match action { ModalAction::None => {} - ModalAction::SaveFile(path) => self.state = DialogState::Selected(path), + ModalAction::SaveFile(path) => self.state = DialogState::Picked(path), }; } @@ -2907,20 +2738,20 @@ impl FileDialog { } match &self.mode { - DialogMode::SelectDirectory | DialogMode::SelectFile => { + DialogMode::PickDirectory | DialogMode::PickFile => { // Should always contain a value since `is_selection_valid` is used to // validate the selection. if let Some(item) = self.selected_item.clone() { - self.state = DialogState::Selected(item.to_path_buf()); + self.state = DialogState::Picked(item.to_path_buf()); } } - DialogMode::SelectMultiple => { + DialogMode::PickMultiple => { let result: Vec = self - .active_selected_entries() + .selected_entries() .map(crate::DirectoryEntry::to_path_buf) .collect(); - self.state = DialogState::SelectedMultiple(result); + self.state = DialogState::PickedMultiple(result); } DialogMode::SaveFile => { // Should always contain a value since `is_selection_valid` is used to @@ -2942,7 +2773,7 @@ impl FileDialog { return; } - self.state = DialogState::Selected(path); + self.state = DialogState::Picked(path); } /// Cancels the dialog. @@ -2979,15 +2810,15 @@ impl FileDialog { /// What is checked depends on the mode the dialog is currently in. fn is_selection_valid(&self) -> bool { match &self.mode { - DialogMode::SelectDirectory => self + DialogMode::PickDirectory => self .selected_item .as_ref() .map_or(false, crate::DirectoryEntry::is_dir), - DialogMode::SelectFile => self + DialogMode::PickFile => self .selected_item .as_ref() .map_or(false, DirectoryEntry::is_file), - DialogMode::SelectMultiple => self.get_dir_content_filtered_iter().any(|p| p.selected), + DialogMode::PickMultiple => self.get_dir_content_filtered_iter().any(|p| p.selected), DialogMode::SaveFile => self.file_name_input_error.is_none(), } } @@ -3022,7 +2853,7 @@ impl FileDialog { /// Marks the given item as the selected directory item. /// Also updates the `file_name_input` to the name of the selected item. fn select_item(&mut self, item: &mut DirectoryEntry) { - if self.mode == DialogMode::SelectMultiple { + if self.mode == DialogMode::PickMultiple { item.selected = true; } self.selected_item = Some(item.clone()); @@ -3152,8 +2983,8 @@ impl FileDialog { let path = self.canonicalize_path(&PathBuf::from(&self.path_edit_value)); - if self.mode == DialogMode::SelectFile && path.is_file() { - self.state = DialogState::Selected(path); + if self.mode == DialogMode::PickFile && path.is_file() { + self.state = DialogState::Picked(path); return; } diff --git a/src/information_panel.rs b/src/information_panel.rs index bc3b1262..99253987 100644 --- a/src/information_panel.rs +++ b/src/information_panel.rs @@ -270,7 +270,7 @@ impl InformationPanel { // Display metadata in a grid format let width = file_dialog.config_mut().right_panel_width.unwrap_or(100.0) / 2.0; - if let Some(item) = file_dialog.active_entry() { + if let Some(item) = file_dialog.selected_entry() { // load file content and additional metadata if it's a new file self.load_meta_data(item); diff --git a/src/lib.rs b/src/lib.rs index 0aa52518..cdda52ec 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,14 +53,14 @@ //! //! impl MyApp { //! fn update(&mut self, ctx: &egui::Context, ui: &mut egui::Ui) { -//! if ui.button("Select file").clicked() { -//! // Open the file dialog to select a file -//! self.file_dialog.select_file(); +//! if ui.button("Pick file").clicked() { +//! // Open the file dialog to pick a file +//! self.file_dialog.pick_file(); //! } //! -//! // Update the dialog and check if the user selected a file -//! if let Some(path) = self.file_dialog.update(ctx).selected() { -//! println!("Selected file: {:?}", path); +//! // Update the dialog and check if the user picked a file +//! if let Some(path) = self.file_dialog.update(ctx).picked() { +//! println!("Picked file: {:?}", path); //! } //! } //! }