diff --git a/src/emain.ts b/src/emain.ts index f88434f9..9856b049 100644 --- a/src/emain.ts +++ b/src/emain.ts @@ -39,11 +39,38 @@ let menu = electron.Menu.buildFromTemplate(menuTemplate); electron.Menu.setApplicationMenu(menu); let MainWindow = null; +let RemotesWindow = null; function getMods(input : any) { return {meta: input.meta, shift: input.shift, ctrl: input.ctrl, alt: input.alt}; } +function cancelNav(event : any, url : any) { + console.log("cancel navigation", url); + event.preventDefault(); +} + +function createRemotesWindow() { + if (RemotesWindow != null) { + console.log("remotes exists"); + return; + } + console.log("create remotes window"); + let win = new electron.BrowserWindow({ + width: 800, + height: 600, + webPreferences: { + preload: path.join(__dirname, "../src/preload.js"), + }, + }); + RemotesWindow = win; + win.loadFile("../static/remotes.html"); + win.on("close", () => { + RemotesWindow = null; + }); + win.webContents.on("will-navigate", cancelNav); +} + function createWindow() { let win = new electron.BrowserWindow({ width: 1800, @@ -73,6 +100,11 @@ function createWindow() { } return; } + if (input.code == "KeyR" && input.meta && input.alt) { + createRemotesWindow(); + e.preventDefault(); + return; + } if (input.meta && (input.code == "ArrowUp" || input.code == "ArrowDown")) { if (input.code == "ArrowUp") { win.webContents.send("meta-arrowup"); @@ -97,6 +129,7 @@ function createWindow() { return; } }); + win.webContents.on("will-navigate", cancelNav); return win; } diff --git a/static/remotes.html b/static/remotes.html new file mode 100644 index 00000000..5b850941 --- /dev/null +++ b/static/remotes.html @@ -0,0 +1 @@ +