jeudi 29 juin 2017

"Never ask again" feature on Electron dialog.showMessageBox method

I have a dialog.showMessageBox that works well and do what I tell it to do.

electron.dialog.showMessageBox({
            type: 'info',
            buttons: ['Yes', 'No'],
            message: 'Are you sure?',
        }, resp => {
            if (resp === 0) {
                // User selected 'Yes'
                foo.bar();
            }
        });

But it's annoying to answer each times this function is called, I'd like to insert a "Never ask again" like this.

electron.dialog.showMessageBox({
            type: 'info',
            buttons: ['Yes', 'No'],
            message: 'Are you sure?',
            checkboxLabel: 'Never ask me again',
            checkboxChecked: false
        }, resp => {
            if (resp === 0) {
                // User selected send
                foo.bar();
            }
        });

Dialog box

The documentation says that the boolean checkboxChecked can be used in the callback function but I'd like to know how to make it global so that the question isn't ask anymore.




Aucun commentaire:

Enregistrer un commentaire