feat: add width option to dialog.showMessageBox() (#30474)

This commit is contained in:
Milan Burda 2021-09-23 12:56:14 +02:00 committed by GitHub
parent e39a1d2ea0
commit 77579614e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

View file

@ -38,6 +38,7 @@ struct MessageBoxSettings {
std::string checkbox_label;
bool checkbox_checked = false;
gfx::ImageSkia icon;
int text_width = 0;
MessageBoxSettings();
MessageBoxSettings(const MessageBoxSettings&);

View file

@ -98,6 +98,12 @@ NSAlert* CreateNSAlert(const MessageBoxSettings& settings) {
[alert setIcon:image];
}
if (settings.text_width > 0) {
NSRect rect = NSMakeRect(0, 0, settings.text_width, 0);
NSView* accessoryView = [[NSView alloc] initWithFrame:rect];
[alert setAccessoryView:[accessoryView autorelease]];
}
return alert;
}

View file

@ -32,6 +32,7 @@ bool Converter<electron::MessageBoxSettings>::FromV8(
dict.Get("noLink", &out->no_link);
dict.Get("checkboxChecked", &out->checkbox_checked);
dict.Get("icon", &out->icon);
dict.Get("textWidth", &out->text_width);
return true;
}