2021-02-08 18:37:25 +11:00
|
|
|
//! Implements a top level menu, with some examples of how to configure and dispatch events.
|
|
|
|
//!
|
|
|
|
//! Some of this might move in to the framework at some point, but it requires a bit more thought.
|
|
|
|
//! Correctly functioning menus are a key part of what makes a macOS app feel right, though, so
|
|
|
|
//! this is here for those who might want to use this todos example as a starting point.
|
|
|
|
|
2021-08-08 15:31:48 +10:00
|
|
|
use cacao::appkit::menu::{Menu, MenuItem};
|
2021-02-08 18:37:25 +11:00
|
|
|
|
|
|
|
use crate::storage::{dispatch_ui, Message};
|
|
|
|
|
|
|
|
/// Installs the menu.
|
|
|
|
pub fn menu() -> Vec<Menu> {
|
|
|
|
vec![
|
2022-08-27 00:40:31 +10:00
|
|
|
Menu::new("", vec![
|
|
|
|
MenuItem::About("Todos".to_string()),
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::new("Preferences").key(",").action(|| {
|
|
|
|
dispatch_ui(Message::OpenPreferencesWindow);
|
|
|
|
}),
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::Services,
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::Hide,
|
|
|
|
MenuItem::HideOthers,
|
|
|
|
MenuItem::ShowAll,
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::Quit,
|
|
|
|
]),
|
|
|
|
Menu::new("File", vec![
|
|
|
|
MenuItem::new("Open/Show Window").key("n").action(|| {
|
|
|
|
dispatch_ui(Message::OpenMainWindow);
|
|
|
|
}),
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::new("Add Todo").key("+").action(|| {
|
|
|
|
dispatch_ui(Message::OpenNewTodoSheet);
|
|
|
|
}),
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::CloseWindow,
|
|
|
|
]),
|
|
|
|
Menu::new("Edit", vec![
|
|
|
|
MenuItem::Undo,
|
|
|
|
MenuItem::Redo,
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::Cut,
|
|
|
|
MenuItem::Copy,
|
|
|
|
MenuItem::Paste,
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::SelectAll,
|
|
|
|
]),
|
2022-07-16 00:14:02 +10:00
|
|
|
Menu::new("View", vec![MenuItem::EnterFullScreen]),
|
2022-08-27 00:40:31 +10:00
|
|
|
Menu::new("Window", vec![
|
|
|
|
MenuItem::Minimize,
|
|
|
|
MenuItem::Zoom,
|
|
|
|
MenuItem::Separator,
|
|
|
|
MenuItem::new("Bring All to Front"),
|
|
|
|
]),
|
2022-07-16 00:14:02 +10:00
|
|
|
Menu::new("Help", vec![]),
|
2021-02-08 18:37:25 +11:00
|
|
|
]
|
|
|
|
}
|