Skip to content

Commit

Permalink
Merge pull request #1339 from linebender/menu_work4
Browse files Browse the repository at this point in the history
Make platform-specific menus more portable
  • Loading branch information
raphlinus authored Oct 29, 2020
2 parents bc96077 + c69619c commit 6a4062d
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions druid/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
//! Creating the default Application menu for macOS:
//!
//! ```
//! use druid::{Data, LocalizedString, MenuDesc, MenuItem, RawMods};
//! use druid::{Data, LocalizedString, MenuDesc, MenuItem, SysMods};
//! use druid::commands;
//!
//! fn macos_application_menu<T: Data>() -> MenuDesc<T> {
Expand All @@ -62,7 +62,7 @@
//! LocalizedString::new("macos-menu-preferences"),
//! commands::SHOW_PREFERENCES,
//! )
//! .hotkey(RawMods::Meta, ",")
//! .hotkey(SysMods::Cmd, ",")
//! .disabled(),
//! )
//! .append_separator()
Expand All @@ -72,14 +72,14 @@
//! LocalizedString::new("macos-menu-hide-app"),
//! commands::HIDE_APPLICATION,
//! )
//! .hotkey(RawMods::Meta, "h"),
//! .hotkey(SysMods::Cmd, "h"),
//! )
//! .append(
//! MenuItem::new(
//! LocalizedString::new("macos-menu-hide-others"),
//! commands::HIDE_OTHERS,
//! )
//! .hotkey(RawMods::AltMeta, "h"),
//! .hotkey(SysMods::AltCmd, "h"),
//! )
//! .append(
//! MenuItem::new(
Expand All @@ -94,7 +94,7 @@
//! LocalizedString::new("macos-menu-quit-app"),
//! commands::QUIT_APP,
//! )
//! .hotkey(RawMods::Meta, "q"),
//! .hotkey(SysMods::Cmd, "q"),
//! )
//! }
//! ```
Expand Down Expand Up @@ -489,7 +489,7 @@ pub mod sys {

#[cfg(target_os = "windows")]
{
item.hotkey(RawMods::Ctrl, "y")
item.hotkey(SysMods::Cmd, "y")
}
#[cfg(not(target_os = "windows"))]
{
Expand Down Expand Up @@ -536,7 +536,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-new"),
commands::NEW_FILE,
)
.hotkey(RawMods::Ctrl, "n")
.hotkey(SysMods::Cmd, "n")
}

/// The 'Open...' menu item.
Expand All @@ -545,7 +545,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-open"),
commands::SHOW_OPEN_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::Ctrl, "o")
.hotkey(SysMods::Cmd, "o")
}

/// The 'Close' menu item.
Expand All @@ -562,7 +562,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save"),
commands::SAVE_FILE.with(None),
)
.hotkey(RawMods::Ctrl, "s")
.hotkey(SysMods::Cmd, "s")
}

/// The 'Save...' menu item.
Expand All @@ -573,7 +573,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save-ellipsis"),
commands::SHOW_SAVE_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::Ctrl, "s")
.hotkey(SysMods::Cmd, "s")
}

/// The 'Save as...' menu item.
Expand All @@ -582,7 +582,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save-as"),
commands::SHOW_SAVE_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::CtrlShift, "S")
.hotkey(SysMods::CmdShift, "S")
}

/// The 'Print...' menu item.
Expand All @@ -591,7 +591,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-print"),
commands::PRINT,
)
.hotkey(RawMods::Ctrl, "p")
.hotkey(SysMods::Cmd, "p")
}

/// The 'Print Preview' menu item.
Expand Down Expand Up @@ -664,7 +664,7 @@ pub mod sys {
LocalizedString::new("macos-menu-preferences"),
commands::SHOW_PREFERENCES,
)
.hotkey(RawMods::Meta, ",")
.hotkey(SysMods::Cmd, ",")
}

/// The 'Hide' builtin menu item.
Expand All @@ -673,7 +673,7 @@ pub mod sys {
LocalizedString::new("macos-menu-hide-app"),
commands::HIDE_APPLICATION,
)
.hotkey(RawMods::Meta, "h")
.hotkey(SysMods::Cmd, "h")
}

/// The 'Hide Others' builtin menu item.
Expand All @@ -682,7 +682,7 @@ pub mod sys {
LocalizedString::new("macos-menu-hide-others"),
commands::HIDE_OTHERS,
)
.hotkey(RawMods::AltMeta, "h")
.hotkey(SysMods::AltCmd, "h")
}

/// The 'show all' builtin menu item
Expand All @@ -700,7 +700,7 @@ pub mod sys {
LocalizedString::new("macos-menu-quit-app"),
commands::QUIT_APP,
)
.hotkey(RawMods::Meta, "q")
.hotkey(SysMods::Cmd, "q")
}
}
/// The file menu.
Expand Down Expand Up @@ -739,7 +739,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-new"),
commands::NEW_FILE,
)
.hotkey(RawMods::Meta, "n")
.hotkey(SysMods::Cmd, "n")
}

/// The 'Open...' menu item. Will display the system file-chooser.
Expand All @@ -748,7 +748,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-open"),
commands::SHOW_OPEN_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::Meta, "o")
.hotkey(SysMods::Cmd, "o")
}

/// The 'Close' menu item.
Expand All @@ -757,7 +757,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-close"),
commands::CLOSE_WINDOW,
)
.hotkey(RawMods::Meta, "w")
.hotkey(SysMods::Cmd, "w")
}

/// The 'Save' menu item.
Expand All @@ -766,7 +766,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save"),
commands::SAVE_FILE.with(None),
)
.hotkey(RawMods::Meta, "s")
.hotkey(SysMods::Cmd, "s")
}

/// The 'Save...' menu item.
Expand All @@ -777,7 +777,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save-ellipsis"),
commands::SHOW_SAVE_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::Meta, "s")
.hotkey(SysMods::Cmd, "s")
}

/// The 'Save as...'
Expand All @@ -786,7 +786,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-save-as"),
commands::SHOW_SAVE_PANEL.with(FileDialogOptions::default()),
)
.hotkey(RawMods::MetaShift, "S")
.hotkey(SysMods::CmdShift, "S")
}

/// The 'Page Setup...' menu item.
Expand All @@ -795,7 +795,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-page-setup"),
commands::PRINT_SETUP,
)
.hotkey(RawMods::MetaShift, "P")
.hotkey(SysMods::CmdShift, "P")
}

/// The 'Print...' menu item.
Expand All @@ -804,7 +804,7 @@ pub mod sys {
LocalizedString::new("common-menu-file-print"),
commands::PRINT,
)
.hotkey(RawMods::Meta, "p")
.hotkey(SysMods::Cmd, "p")
}
}
}
Expand Down

0 comments on commit 6a4062d

Please # to comment.