checkpoint

This commit is contained in:
sawka
2022-07-12 14:27:40 -07:00
parent 7867edb8da
commit 4666ee8832
3 changed files with 29 additions and 2 deletions
+16 -1
View File
@@ -53,8 +53,23 @@ function createWindow() {
if (input.type != "keyDown") {
return;
}
if (input.meta) {
console.log("before-input", input.code, input.modifiers);
}
if (input.code == "KeyT" && input.meta) {
win.webContents.send("cmt-t");
win.webContents.send("cmd-t");
e.preventDefault();
return;
}
if (input.code == "BracketRight" && input.meta) {
win.webContents.send("switch-screen", {relative: 1});
e.preventDefault();
return;
}
if (input.code == "BracketLeft" && input.meta) {
win.webContents.send("switch-screen", {relative: -1});
e.preventDefault();
return;
}
});
return win;
+11
View File
@@ -19,6 +19,7 @@ function isBlank(s : string) {
type ElectronApi = {
getId : () => string,
onCmdT : (callback : () => void) => void,
onSwitchScreen : (callback : (event : any, arg : {relative? : number, absolute? : number}) => void) => void,
};
function getApi() : ElectronApi {
@@ -405,6 +406,16 @@ class Model {
this.loadSessionList();
this.ws = new WSControl(this.clientId, this.onWSMessage.bind(this))
this.ws.reconnect();
getApi().onCmdT(this.onCmdT.bind(this));
getApi().onSwitchScreen(this.onSwitchScreen.bind(this));
}
onCmdT() {
console.log("got cmd-t");
}
onSwitchScreen(e : any, arg : {relative? : number, absolute? : number}) {
console.log("switch screen", arg);
}
isConnected() : boolean {
+2 -1
View File
@@ -2,5 +2,6 @@ let {contextBridge, ipcRenderer} = require("electron");
contextBridge.exposeInMainWorld("api", {
getId: () => ipcRenderer.sendSync("get-id"),
onCmdT: (callback) => ipcRenderer.on("cmd-t"),
onCmdT: (callback) => ipcRenderer.on("cmd-t", callback),
onSwitchScreen: (callback) => ipcRenderer.on("switch-screen", callback),
});