From edc1a9614c4568af485c3fcc49533a44ea880f89 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 8 Aug 2016 00:02:32 +0200 Subject: [PATCH] Add macOS specific speaking roles for MenuItem --- atom/browser/ui/cocoa/atom_menu_controller.mm | 2 ++ default_app/main.js | 16 ++++++++++++++++ docs/api/menu-item.md | 2 ++ docs/api/menu.md | 17 +++++++++++++++++ lib/browser/api/menu-item-roles.js | 6 ++++++ 5 files changed, 43 insertions(+) diff --git a/atom/browser/ui/cocoa/atom_menu_controller.mm b/atom/browser/ui/cocoa/atom_menu_controller.mm index 3efd161151..525fde28b1 100644 --- a/atom/browser/ui/cocoa/atom_menu_controller.mm +++ b/atom/browser/ui/cocoa/atom_menu_controller.mm @@ -35,6 +35,8 @@ Role kRolesMap[] = { { @selector(delete:), "delete" }, { @selector(pasteAndMatchStyle:), "pasteandmatchstyle" }, { @selector(selectAll:), "selectall" }, + { @selector(startSpeaking:), "startspeaking" }, + { @selector(stopSpeaking:), "stopspeaking" }, { @selector(performMiniaturize:), "minimize" }, { @selector(performClose:), "close" }, { @selector(performZoom:), "zoom" }, diff --git a/default_app/main.js b/default_app/main.js index b4d74d8109..ead6adff67 100644 --- a/default_app/main.js +++ b/default_app/main.js @@ -217,6 +217,22 @@ app.once('ready', () => { } ] }) + template[1].submenu.push( + { + type: 'separator' + }, + { + label: 'Speech', + submenu: [ + { + role: 'startspeaking' + }, + { + role: 'stopspeaking' + } + ] + } + ) template[3].submenu = [ { role: 'close' diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index 3a9a565a9d..a40cad49f4 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -63,6 +63,8 @@ On macOS `role` can also have following additional values: * `hide` - Map to the `hide` action * `hideothers` - Map to the `hideOtherApplications` action * `unhide` - Map to the `unhideAllApplications` action +* `startspeaking` - Map to the `startSpeaking` action +* `stopspeaking` - Map to the `stopSpeaking` action * `front` - Map to the `arrangeInFront` action * `zoom` - Map to the `performZoom` action * `window` - The submenu is a "Window" menu diff --git a/docs/api/menu.md b/docs/api/menu.md index d4163c5f15..e04ff09d2c 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -133,6 +133,23 @@ if (process.platform === 'darwin') { } ] }) + // Edit menu. + template[1].submenu.push( + { + type: 'separator' + }, + { + label: 'Speech', + submenu: [ + { + role: 'startspeaking' + }, + { + role: 'stopspeaking' + } + ] + } + ) // Window menu. template[3].submenu = [ { diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index 17447ffc66..526b60fcc1 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -80,6 +80,12 @@ const roles = { services: { label: 'Services' }, + startspeaking: { + label: 'Start Speaking' + }, + stopspeaking: { + label: 'Stop Speaking' + }, togglefullscreen: { label: 'Toggle Full Screen', accelerator: process.platform === 'darwin' ? 'Control+Command+F' : 'F11',