electron#MessageBoxOptions TypeScript Examples

The following examples show how to use electron#MessageBoxOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: sentry.ts    From electron-playground with MIT License 6 votes vote down vote up
/**
 * Crash listen on the created window
 * @param win BrowserWindow
 */
export function addCrashListener(win: BrowserWindow) {
  // https://www.electronjs.org/docs/api/web-contents#event-crashed-deprecated
  win.webContents.on('crashed', async (event,killed) => {
    console.log(event,killed)
    const options: MessageBoxOptions = {
      type: 'info',
      title: 'The renderer process crashes',
      message: 'The renderer process crashes.',
      buttons: ['quit app', 'reload'],
    }
    const { response } = await dialog.showMessageBox(win, options)
    // 1 reload 0 quit app
    response ? win.reload() : app.quit()
  })
}
Example #2
Source File: index.ts    From TidGi-Desktop with Mozilla Public License 2.0 5 votes vote down vote up
public async showElectronMessageBox(message: string, type: MessageBoxOptions['type'] = 'info', windowName = WindowNames.main): Promise<void> {
    const window = this.windowService.get(windowName);
    if (window !== undefined) {
      await dialog.showMessageBox(window, { message, type });
    }
  }