diff --git a/CHANGELOG.md b/CHANGELOG.md index 04abce28f3..fbfe0624b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ You can find its changes [documented below](#060---2020-06-01). ### Highlights ### Added +- `OPEN_PANEL_CANCELLED` and `SAVE_PANEL_CANCELLED` commands. ([#1061] by @cmyr) - Export `Image` and `ImageData` by default. ([#1011] by [@covercash2]) - Re-export `druid_shell::Scalable` under `druid` namespace. ([#1075] by [@ForLoveOfCats]) @@ -360,6 +361,7 @@ Last release without a changelog :( [#1050]: https://github.com/linebender/druid/pull/1050 [#1054]: https://github.com/linebender/druid/pull/1054 [#1058]: https://github.com/linebender/druid/pull/1058 +[#1061]: https://github.com/linebender/druid/pull/1061 [#1062]: https://github.com/linebender/druid/pull/1062 [#1072]: https://github.com/linebender/druid/pull/1072 [#1075]: https://github.com/linebender/druid/pull/1075 @@ -375,4 +377,3 @@ Last release without a changelog :( [0.4.0]: https://github.com/linebender/druid/compare/v0.3.2...v0.4.0 [0.3.2]: https://github.com/linebender/druid/compare/v0.3.1...v0.3.2 [0.3.1]: https://github.com/linebender/druid/compare/v0.3.0...v0.3.1 - diff --git a/druid/src/command.rs b/druid/src/command.rs index 5ee731b65c..849f998519 100644 --- a/druid/src/command.rs +++ b/druid/src/command.rs @@ -193,6 +193,9 @@ pub mod sys { pub const SHOW_OPEN_PANEL: Selector = Selector::new("druid-builtin.menu-file-open"); + /// Sent when the user cancels an open file panel. + pub const OPEN_PANEL_CANCELLED: Selector = Selector::new("druid-builtin.open-panel-cancelled"); + /// Open a file, must be handled by the application. /// /// [`FileInfo`]: ../struct.FileInfo.html @@ -206,6 +209,9 @@ pub mod sys { pub const SHOW_SAVE_PANEL: Selector = Selector::new("druid-builtin.menu-file-save-as"); + /// Sent when the user cancels a save file panel. + pub const SAVE_PANEL_CANCELLED: Selector = Selector::new("druid-builtin.save-panel-cancelled"); + /// Save the current file, must be handled by the application. /// /// How this should be handled depends on the payload: diff --git a/druid/src/win_handler.rs b/druid/src/win_handler.rs index 55c9b3bfed..7a9f9785df 100644 --- a/druid/src/win_handler.rs +++ b/druid/src/win_handler.rs @@ -581,6 +581,9 @@ impl AppState { if let Some(info) = result { let cmd = Command::new(sys_cmd::OPEN_FILE, info); self.inner.borrow_mut().dispatch_cmd(window_id.into(), cmd); + } else { + let cmd = sys_cmd::OPEN_PANEL_CANCELLED.into(); + self.inner.borrow_mut().dispatch_cmd(window_id.into(), cmd); } } @@ -596,6 +599,9 @@ impl AppState { if let Some(info) = result { let cmd = Command::new(sys_cmd::SAVE_FILE, Some(info)); self.inner.borrow_mut().dispatch_cmd(window_id.into(), cmd); + } else { + let cmd = sys_cmd::SAVE_PANEL_CANCELLED.into(); + self.inner.borrow_mut().dispatch_cmd(window_id.into(), cmd); } }