fix: focus rings with multiple buttons in showMessageBox (#36772)

fix: focus rings with multiple buttons in messageBox
This commit is contained in:
Shelley Vohr 2023-01-05 09:56:38 +01:00 committed by GitHub
parent 42cda4a893
commit 32288ac9c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -71,9 +71,6 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
int button_count = static_cast<int>([ns_buttons count]);
if (settings.default_id >= 0 && settings.default_id < button_count) {
// Highlight the button at default_id
[[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
// The first button added gets set as the default selected, so remove
// that and set the button @ default_id to be default.
[[ns_buttons objectAtIndex:0] setKeyEquivalent:@""];
@ -86,6 +83,11 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
[[ns_buttons objectAtIndex:settings.cancel_id] setKeyEquivalent:@"\e"];
}
// TODO(@codebytere): This behavior violates HIG & should be deprecated.
if (settings.cancel_id >= 0 && settings.cancel_id == settings.default_id) {
[[ns_buttons objectAtIndex:settings.default_id] highlight:YES];
}
if (!settings.checkbox_label.empty()) {
alert.showsSuppressionButton = YES;
alert.suppressionButton.title =