proof of concept, open window

This commit is contained in:
sawka 2022-08-17 13:26:03 -07:00
parent 5a835e927e
commit c6e29c3314
2 changed files with 34 additions and 0 deletions

View File

@ -39,11 +39,38 @@ let menu = electron.Menu.buildFromTemplate(menuTemplate);
electron.Menu.setApplicationMenu(menu); electron.Menu.setApplicationMenu(menu);
let MainWindow = null; let MainWindow = null;
let RemotesWindow = null;
function getMods(input : any) { function getMods(input : any) {
return {meta: input.meta, shift: input.shift, ctrl: input.ctrl, alt: input.alt}; 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() { function createWindow() {
let win = new electron.BrowserWindow({ let win = new electron.BrowserWindow({
width: 1800, width: 1800,
@ -73,6 +100,11 @@ function createWindow() {
} }
return; return;
} }
if (input.code == "KeyR" && input.meta && input.alt) {
createRemotesWindow();
e.preventDefault();
return;
}
if (input.meta && (input.code == "ArrowUp" || input.code == "ArrowDown")) { if (input.meta && (input.code == "ArrowUp" || input.code == "ArrowDown")) {
if (input.code == "ArrowUp") { if (input.code == "ArrowUp") {
win.webContents.send("meta-arrowup"); win.webContents.send("meta-arrowup");
@ -97,6 +129,7 @@ function createWindow() {
return; return;
} }
}); });
win.webContents.on("will-navigate", cancelNav);
return win; return win;
} }

1
static/remotes.html Normal file
View File

@ -0,0 +1 @@
<h1>Remotes!</h1>