diff options
Diffstat (limited to 'Source/SPAlertSheets.m')
-rw-r--r-- | Source/SPAlertSheets.m | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/Source/SPAlertSheets.m b/Source/SPAlertSheets.m index 85afbdfb..d19da6df 100644 --- a/Source/SPAlertSheets.m +++ b/Source/SPAlertSheets.m @@ -149,12 +149,14 @@ * Because of that there is no way to set a delegate and callback method * and there is only one default button. * If nil is passed as the button title it will be changed to @"OK". + * If nil is passed as the window NSAlert will be modal */ void SPOnewayAlertSheet( NSString *title, NSString *defaultButton, NSWindow *docWindow, - NSString *msg) + NSString *msg, + NSAlertStyle alertStyle) { NSString *defaultText = (defaultButton)? defaultButton : NSLocalizedString(@"OK", @"OK button"); @@ -168,12 +170,17 @@ void SPOnewayAlertSheet( // Set the informative message if supplied if (msg) [alert setInformativeText:msg]; + + // Set style (Defaults to NSWarningAlertStyle) + [alert setAlertStyle:alertStyle]; // Run the alert - [alert beginSheetModalForWindow:docWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; - - // Ensure the alerting window is frontmost - [docWindow makeKeyWindow]; + if (docWindow) { + [alert beginSheetModalForWindow:docWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; + [docWindow makeKeyWindow]; // Ensure the alerting window is frontmost + } else { + [alert runModal]; + } }); } |