From 7ea207327fb1d1af2e4057f2bfad6c71edadab75 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Thu, 21 Feb 2019 23:23:58 +0000 Subject: [PATCH] hey it all works --- electron_app/package.json | 15 --------------- src/vector/platform/ElectronPlatform.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/electron_app/package.json b/electron_app/package.json index 08f8de39..fff68a7f 100644 --- a/electron_app/package.json +++ b/electron_app/package.json @@ -12,21 +12,6 @@ "minimist": "^1.2.0", "png-to-ico": "^1.0.2" }, - "iohook": { - "targets": [ - "node-64", - "electron-69" - ], - "platforms": [ - "win32", - "darwin", - "linux" - ], - "arches": [ - "x64", - "ia32" - ] - }, "cmake-js": { "runtime": "electron", "runtimeVersion": "4.0.4" diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index c81f3687..ed7a600a 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -218,6 +218,25 @@ export default class ElectronPlatform extends VectorBasePlatform { ipcRenderer.send('check_updates'); } + startListeningKeys() { + // Tell iohook to start listening for key events + ipcRenderer.send('start-listening-keys'); + } + + stopListeningKeys() { + // Tell iohook to stop listening for key events + ipcRenderer.send('stop-listening-keys'); + } + + onKeypress(self: any, callback: (ev, event) => void ) { + ipcRenderer.on('keypress', callback.bind(self)); + } + + onWindowBlurred(callback: () => void) { + // Callback to run on window blur (window loses focus) + ipcRenderer.on('window-blurred', callback); + } + addGlobalKeybinding(keybindName: string, keybindCode: string, callback: () => void, releaseCallback: () => void) { // Add a keybinding that works even when the app is minimized const keybinding = {name: keybindName, code: keybindCode};