Fix copy-paste not working on macOS

This commit is contained in:
Krishan 2022-05-16 16:30:01 +05:30
parent 912d7394ab
commit 1ecdddde26
2 changed files with 51 additions and 2 deletions

View file

@ -3,8 +3,16 @@
windows_subsystem = "windows"
)]
#[cfg(target_os = "macos")]
mod menu;
fn main() {
tauri::Builder::default()
let builder = tauri::Builder::default();
#[cfg(target_os = "macos")]
let builder = builder.menu(menu::menu());
builder
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
}

41
src-tauri/src/menu.rs Normal file
View file

@ -0,0 +1,41 @@
use tauri::{AboutMetadata, Menu, MenuItem, Submenu};
//for macOS
pub(crate) fn menu() -> Menu {
Menu::new()
.add_submenu(Submenu::new(
"Cinny",
Menu::new()
.add_native_item(MenuItem::About(
"Cinny".to_string(),
AboutMetadata::new(),
))
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Hide)
.add_native_item(MenuItem::HideOthers)
.add_native_item(MenuItem::ShowAll)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Quit),
))
.add_submenu(Submenu::new(
"Edit",
Menu::new()
.add_native_item(MenuItem::Undo)
.add_native_item(MenuItem::Redo)
.add_native_item(MenuItem::Separator)
.add_native_item(MenuItem::Cut)
.add_native_item(MenuItem::Copy)
.add_native_item(MenuItem::Paste)
.add_native_item(MenuItem::SelectAll),
))
.add_submenu(Submenu::new(
"View",
Menu::new()
.add_native_item(MenuItem::EnterFullScreen),
))
.add_submenu(Submenu::new(
"Window",
Menu::new()
.add_native_item(MenuItem::Minimize)
.add_native_item(MenuItem::Zoom),
))
}