Skip to content

Commit

Permalink
feat: use local shortcut for quit (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux committed Apr 21, 2022
1 parent 49769de commit b5f3b2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const {
shell,
Menu,
Tray,
globalShortcut,
} = require('electron');
const singleInstanceLock = app.requestSingleInstanceLock();

Expand Down Expand Up @@ -128,6 +127,14 @@ function createMainWindow() {
}
return { action: 'allow' };
});
const onInputEvent = (event, input) => {
if ((input.control || input.meta) && input.key.toLowerCase() === 'q') {
console.log('Pressed Control/Command+Q')
app.quit();
}
};
mainWindow.webContents.on('before-input-event', onInputEvent);
mainView.webContents.on('before-input-event', onInputEvent);
// open dev tool default
if (process.env.DEBUG == 1) {
mainView.webContents.openDevTools();
Expand Down Expand Up @@ -192,10 +199,6 @@ if (!singleInstanceLock) {
app.quit();
} else {
app.whenReady().then(() => {
globalShortcut.register('CommandOrControl+Q', () => {
app.quit();
});
}).then(() => {
createMainWindow();
process.argv.forEach((cmd) => {
handleCustomizedSchemeUri(cmd);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ringcentral-embeddable-voice-app",
"description": "A RingCentral phone desktop client, built with RingCentral Embeddable and Electron",
"version": "0.2.0",
"version": "0.2.2",
"main": "main.js",
"license": "MIT",
"author": {
Expand Down

0 comments on commit b5f3b2e

Please sign in to comment.