Skip to content

Commit

Permalink
docs: update readme to use new pick methods (fluxxcode#214)
Browse files Browse the repository at this point in the history
* docs: update readme to include new pick methods

* Update changelog
  • Loading branch information
fluxxcode authored Dec 17, 2024
1 parent 51be318 commit 0f75ef8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
### 📚 Documentation

- Updated `README.md` to include latest features [#176](https://github.com/fluxxcode/egui-file-dialog/pull/176)
- Updated `README.md` to use new `pick_*` methods [#214](https://github.com/fluxxcode/egui-file-dialog/pull/214)

## 2024-10-01 - v0.7.0 - egui update and QoL changes

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ The file dialog is intended for use by desktop applications, allowing the use of
The latest changes included in the next release can be found in the [CHANGELOG.md](https://github.com/fluxxcode/egui-file-dialog/blob/develop/CHANGELOG.md) file on the develop branch.

## Features

- Pick a file or a directory
- Select a file or a directory
- Save a file (Prompt user for a destination path)
- Dialog to ask the user if the existing file should be overwritten
- Select multiple files and folders at once (ctrl/shift + click on linux/windows and cmd/shift + click on macOS)
- Pick multiple files and folders at once (ctrl/shift + click on linux/windows and cmd/shift + click on macOS)
- Open the dialog in a normal or modal window
- Create a new folder
- Keyboard navigation
Expand Down Expand Up @@ -76,35 +76,35 @@ use egui_file_dialog::FileDialog;

struct MyApp {
file_dialog: FileDialog,
selected_file: Option<PathBuf>,
picked_file: Option<PathBuf>,
}

impl MyApp {
pub fn new(_cc: &eframe::CreationContext) -> Self {
Self {
// Create a new file dialog object
file_dialog: FileDialog::new(),
selected_file: None,
picked_file: None,
}
}
}

impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |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();
}

ui.label(format!("Selected file: {:?}", self.selected_file));
ui.label(format!("Picked file: {:?}", self.picked_file));

// Update the dialog
self.file_dialog.update(ctx);

// Check if the user selected a file.
if let Some(path) = self.file_dialog.take_selected() {
self.selected_file = Some(path.to_path_buf());
// Check if the user picked a file.
if let Some(path) = self.file_dialog.take_picked() {
self.picked_file = Some(path.to_path_buf());
}
});
}
Expand Down

0 comments on commit 0f75ef8

Please sign in to comment.