Merge pull request #67564 from bruvzg/macos_wide_alert

[macOS] Fit OS::alert to the text width for better readability.
This commit is contained in:
Max Hilbrunner 2022-10-19 21:52:40 +02:00 committed by GitHub
commit 21c90b4c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,9 +148,11 @@ void OS_MacOS::alert(const String &p_alert, const String &p_title) {
NSString *ns_title = [NSString stringWithUTF8String:p_title.utf8().get_data()];
NSString *ns_alert = [NSString stringWithUTF8String:p_alert.utf8().get_data()];
NSTextField *text_field = [NSTextField labelWithString:ns_alert];
[text_field setAlignment:NSTextAlignmentCenter];
[window addButtonWithTitle:@"OK"];
[window setMessageText:ns_title];
[window setInformativeText:ns_alert];
[window setAccessoryView:text_field];
[window setAlertStyle:NSAlertStyleWarning];
id key_window = [[NSApplication sharedApplication] keyWindow];