fix: set default_id and cancel_id correctly on confirm dialogs (#17547)
This commit is contained in:
parent
4e57a732a8
commit
2188a6ea99
1 changed files with 9 additions and 2 deletions
|
@ -52,9 +52,16 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No default button
|
||||||
|
int default_id = -1;
|
||||||
|
int cancel_id = 0;
|
||||||
|
|
||||||
std::vector<std::string> buttons = {"OK"};
|
std::vector<std::string> buttons = {"OK"};
|
||||||
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
if (dialog_type == JavaScriptDialogType::JAVASCRIPT_DIALOG_TYPE_CONFIRM) {
|
||||||
buttons.push_back("Cancel");
|
buttons.push_back("Cancel");
|
||||||
|
// First button is default, second button is cancel
|
||||||
|
default_id = 0;
|
||||||
|
cancel_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
origin_counts_[origin]++;
|
origin_counts_[origin]++;
|
||||||
|
@ -76,8 +83,8 @@ void AtomJavaScriptDialogManager::RunJavaScriptDialog(
|
||||||
}
|
}
|
||||||
|
|
||||||
atom::ShowMessageBox(
|
atom::ShowMessageBox(
|
||||||
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, -1, 0,
|
window, atom::MessageBoxType::MESSAGE_BOX_TYPE_NONE, buttons, default_id,
|
||||||
atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
cancel_id, atom::MessageBoxOptions::MESSAGE_BOX_NONE, "",
|
||||||
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
|
base::UTF16ToUTF8(message_text), "", checkbox, false, gfx::ImageSkia(),
|
||||||
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
base::Bind(&AtomJavaScriptDialogManager::OnMessageBoxCallback,
|
||||||
base::Unretained(this), base::Passed(std::move(callback)),
|
base::Unretained(this), base::Passed(std::move(callback)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue