Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OPEN_PANEL_CANCELLED and SAVE_PANEL_CANCELLED commands #1061

Merged
merged 1 commit into from
Jul 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

- Added ctrl/shift key support to textbox. ([#1063] by [@vkahl])

Expand Down Expand Up @@ -351,6 +352,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
[#1081]: https://github.com/linebender/druid/pull/1081

Expand All @@ -360,4 +362,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

6 changes: 6 additions & 0 deletions druid/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ pub mod sys {
pub const SHOW_OPEN_PANEL: Selector<FileDialogOptions> =
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
Expand All @@ -206,6 +209,9 @@ pub mod sys {
pub const SHOW_SAVE_PANEL: Selector<FileDialogOptions> =
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:
Expand Down
6 changes: 6 additions & 0 deletions druid/src/win_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ impl<T: Data> AppState<T> {
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);
}
}

Expand All @@ -596,6 +599,9 @@ impl<T: Data> AppState<T> {
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);
}
}

Expand Down