feat: add registerAccelerator flag to allow menu items to optionally skip accelerator registration (backport: 3-1-x) (#15892)
* feat: add registerAccelerator flag to allow menu items to skip registration * docs: add docs for registerAccelerator
This commit is contained in:
parent
bb28fa8e8e
commit
6d5b225ac5
9 changed files with 43 additions and 7 deletions
|
@ -14,12 +14,14 @@ const roles = {
|
|||
copy: {
|
||||
label: 'Copy',
|
||||
accelerator: 'CommandOrControl+C',
|
||||
webContentsMethod: 'copy'
|
||||
webContentsMethod: 'copy',
|
||||
registerAccelerator: false
|
||||
},
|
||||
cut: {
|
||||
label: 'Cut',
|
||||
accelerator: 'CommandOrControl+X',
|
||||
webContentsMethod: 'cut'
|
||||
webContentsMethod: 'cut',
|
||||
registerAccelerator: false
|
||||
},
|
||||
delete: {
|
||||
label: 'Delete',
|
||||
|
@ -57,12 +59,14 @@ const roles = {
|
|||
paste: {
|
||||
label: 'Paste',
|
||||
accelerator: 'CommandOrControl+V',
|
||||
webContentsMethod: 'paste'
|
||||
webContentsMethod: 'paste',
|
||||
registerAccelerator: false
|
||||
},
|
||||
pasteandmatchstyle: {
|
||||
label: 'Paste and Match Style',
|
||||
accelerator: 'Shift+CommandOrControl+V',
|
||||
webContentsMethod: 'pasteAndMatchStyle'
|
||||
webContentsMethod: 'pasteAndMatchStyle',
|
||||
registerAccelerator: false
|
||||
},
|
||||
quit: {
|
||||
get label () {
|
||||
|
@ -241,6 +245,10 @@ exports.getDefaultAccelerator = (role) => {
|
|||
if (roles.hasOwnProperty(role)) return roles[role].accelerator
|
||||
}
|
||||
|
||||
exports.shouldRegisterAccelerator = (role) => {
|
||||
return roles.hasOwnProperty(role) ? roles[role].registerAccelerator : true
|
||||
}
|
||||
|
||||
exports.getDefaultSubmenu = (role) => {
|
||||
if (!roles.hasOwnProperty(role)) return
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue