mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-22 08:57:00 -06:00
Added a closeScreenSnippet command
This commit is contained in:
parent
21af4338b9
commit
d3d53dc2d1
@ -117,6 +117,9 @@ ipcMain.on(apiName.symphonyApi, (event: Electron.IpcMainEvent, arg: IApiArgs) =>
|
||||
case apiCmds.openScreenSnippet:
|
||||
screenSnippet.capture(event.sender);
|
||||
break;
|
||||
case apiCmds.closeScreenSnippet:
|
||||
screenSnippet.cancelCapture();
|
||||
break;
|
||||
case apiCmds.closeWindow:
|
||||
windowHandler.closeWindow(arg.windowType, arg.winKey);
|
||||
break;
|
||||
|
@ -67,6 +67,22 @@ class ScreenSnippet {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels a screen capture and closes the snippet window
|
||||
*
|
||||
* @param webContents {Electron.webContents}
|
||||
*/
|
||||
public async cancelCapture() {
|
||||
logger.info(`screen-snippet-handler: Cancel screen capture!`);
|
||||
this.focusedWindow = BrowserWindow.getFocusedWindow();
|
||||
|
||||
try {
|
||||
await this.execCmd(this.captureUtil, []);
|
||||
} catch (error) {
|
||||
logger.error(`screen-snippet-handler: screen capture cancedl failed with error: ${error}!`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kills the child process when the application is reloaded
|
||||
*/
|
||||
|
@ -19,6 +19,7 @@ export enum apiCmds {
|
||||
setIsInMeeting = 'set-is-in-meeting',
|
||||
setLocale = 'set-locale',
|
||||
openScreenSnippet = 'open-screen-snippet',
|
||||
closeScreenSnippet = 'close-screen-snippet',
|
||||
keyPress = 'key-press',
|
||||
closeWindow = 'close-window',
|
||||
openScreenSharingIndicator = 'open-screen-sharing-indicator',
|
||||
|
@ -124,6 +124,7 @@
|
||||
<button id='snippet'>get snippet</button>
|
||||
<p>snippet output:</p>
|
||||
<image id='snippet-img'/>
|
||||
<button id='cancel-snippet'>cancel snippet</button>
|
||||
|
||||
<hr>
|
||||
<p>Window activate:</p>
|
||||
@ -187,6 +188,7 @@
|
||||
setIsInMeeting: 'set-is-in-meeting',
|
||||
setLocale: 'set-locale',
|
||||
openScreenSnippet: 'open-screen-snippet',
|
||||
closeScreenSnippet: 'close-screen-snippet',
|
||||
keyPress: 'key-press',
|
||||
closeWindow: 'close-window',
|
||||
openScreenSharingIndicator: 'open-screen-sharing-indicator',
|
||||
@ -310,6 +312,16 @@
|
||||
}
|
||||
});
|
||||
|
||||
const cancelSnippetButton = document.getElementById('cancel-snippet');
|
||||
cancelSnippetButton.addEventListener('click', () => {
|
||||
if (window.ssf) {
|
||||
const screenSnippet = new window.ssf.ScreenSnippet();
|
||||
screenSnippet.cancelCapture();
|
||||
} else {
|
||||
postMessage(apiCmds.closeScreenSnippet)
|
||||
}
|
||||
});
|
||||
|
||||
let win;
|
||||
|
||||
const openWinButton = document.getElementById('open-win');
|
||||
|
@ -114,6 +114,9 @@ export class AppBridge {
|
||||
case apiCmds.openScreenSnippet:
|
||||
ssf.openScreenSnippet(this.callbackHandlers.onScreenSnippetCallback);
|
||||
break;
|
||||
case apiCmds.closeScreenSnippet:
|
||||
ssf.closeScreenSnippet();
|
||||
break;
|
||||
case apiCmds.registerBoundsChange:
|
||||
ssf.registerBoundsChange(this.callbackHandlers.onRegisterBoundsChangeCallback);
|
||||
break;
|
||||
|
@ -24,4 +24,14 @@ export class ScreenSnippetBcHandler {
|
||||
});
|
||||
});
|
||||
}
|
||||
/**
|
||||
* cancel capture method to support backward compatibility
|
||||
*
|
||||
* @deprecated user closeScreenSnippet instead
|
||||
*/
|
||||
public cancel() {
|
||||
ipcRenderer.send(apiName.symphonyApi, {
|
||||
cmd: apiCmds.closeScreenSnippet,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -302,6 +302,17 @@ export class SSFApi {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a screen capture in progress
|
||||
*
|
||||
* @param screenSnippetCallback {function}
|
||||
*/
|
||||
public closeScreenSnippet(): void {
|
||||
local.ipcRenderer.send(apiName.symphonyApi, {
|
||||
cmd: apiCmds.closeScreenSnippet,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the count on the tray icon to the given number.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user