Skip to content

Commit

Permalink
A native question dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
felixrieseberg committed Aug 31, 2017
1 parent c199638 commit 837c081
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { app, BrowserWindow } = require('electron')
const { app, BrowserWindow, dialog } = require('electron')

let mainWindow

Expand All @@ -11,10 +11,22 @@ app.on('ready', () => {
height: 800
})

mainWindow.webContents.on('dom-ready', () => {
// The window has loaded its contents
mainWindow.show()
})

mainWindow.loadURL(`file://${__dirname}/../renderer/index.html`)

const buttons = ['Yes', 'No']
const options = {
type: 'question',
buttons,
title: 'Show window?',
message: 'Do you want to show the window?',
detail: 'Choose carefully!'
}

dialog.showMessageBox(options, (response) => {
const selected = buttons[response]

if (selected === 'Yes') {
mainWindow.show()
}
})
})

0 comments on commit 837c081

Please sign in to comment.