Well, I have quite a simple task, which can't be really hard. I have an app, which uses the electron framework to use the application on Windows and Mac machines. I notices that I am able to use Ctrl+c/Ctrl+v on Windows without any problems, but I am not able to use Cmd+c/Cmd+v on Mac after I used the electron-packager.
I found solutions like this (CMD + C / CMD + V not working), but I have a custom menue and I don't want to define and use the one in electron itself. So I found this (global accelerators without menue, but the issue is still open and there seems to be no solution. Solutions like this (Local-Shortcut) are also not usable, as they don't get the selected text (e.g. from a textbox) as a parameter.
I think using Cmd+c / Cmd+v shouldn't be a real issue, since it is a common action in every application, but I don't see a usable solution at the moment. This also effects all other shortcuts like Cmd+a to select everything.
To use a keyboard shortcut, press and hold one or more modifier keys and then press the last key of the shortcut. For example, to use Command-C (copy), press and hold the Command key, then the C key, then release both keys.
Control-E: Move to the end of a line or paragraph. Control-F: Move one character forward. Control-B: Move one character backward. Control-L: Center the cursor or selection in the visible area.
There seems to be no way of doing it if you really want to hide these shortcuts from the menu.
At the moment, the best workaround is to display the shortcuts menu on MacOS only:
const { Menu } = require('electron')
const menuTemplate = [...];
if (process.platform === 'darwin') {
menuTemplate.push({
label: 'Edit',
submenu: [
{role: 'undo'},
{role: 'redo'},
{type: 'separator'},
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{role: 'pasteandmatchstyle'},
{role: 'delete'},
{role: 'selectall'}
]
})
}
const applicationMenu = Menu.buildFromTemplate(menuTemplate)
Menu.setApplicationMenu(applicationMenu)
https://blog.avocode.com/blog/4-must-know-tips-for-building-cross-platform-electron-apps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With