我可以在电子中设置默认焦点按钮 showMessageBox 吗?
Can I set default focus button showMessageBox in electron?
在应用程序退出确认对话框中,我想要一种方法来将默认聚焦的按钮设置为否 (N)。
另外,Yes (Y), No (N) 想按这个顺序排列(我不想用一种方法把 No (N) 排到左边)。
function confirm_dialog(strtitle, strmessage) {
const {dialog} = require('electron').remote;
let choice = dialog.showMessageBox(
remote.getCurrentWindow(),
{
type: 'question',
buttons: ['Yes', 'No'],
title: strtitle,
message: strmessage,
});
return choice === 0;
};
confirm dialog
showMessgeBox
docs解释一下:
defaultId
Integer (optional) - Index of the button in the buttons array which will be selected by default when the message box opens.
在应用程序退出确认对话框中,我想要一种方法来将默认聚焦的按钮设置为否 (N)。
另外,Yes (Y), No (N) 想按这个顺序排列(我不想用一种方法把 No (N) 排到左边)。
function confirm_dialog(strtitle, strmessage) {
const {dialog} = require('electron').remote;
let choice = dialog.showMessageBox(
remote.getCurrentWindow(),
{
type: 'question',
buttons: ['Yes', 'No'],
title: strtitle,
message: strmessage,
});
return choice === 0;
};
confirm dialog
showMessgeBox
docs解释一下:
defaultId
Integer (optional) - Index of the button in the buttons array which will be selected by default when the message box opens.