mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
showAlert: legacy OS compatibility fix
This commit is contained in:

committed by
Sam Lantinga

parent
123b967a99
commit
ed0eb7714a
@@ -33,6 +33,9 @@
|
||||
NSWindow *nswindow;
|
||||
}
|
||||
- (id)initWithParentWindow:(SDL_Window *)window;
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
|
||||
- (void)alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;
|
||||
#endif
|
||||
@end
|
||||
|
||||
@implementation SDLMessageBoxPresenter
|
||||
@@ -56,16 +59,32 @@
|
||||
- (void)showAlert:(NSAlert*)alert
|
||||
{
|
||||
if (nswindow) {
|
||||
[alert beginSheetModalForWindow:nswindow
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1090
|
||||
if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) {
|
||||
[alert beginSheetModalForWindow:nswindow
|
||||
completionHandler:^(NSModalResponse returnCode) {
|
||||
[NSApp stopModalWithCode:returnCode];
|
||||
}];
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
|
||||
[alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
|
||||
#endif
|
||||
}
|
||||
clicked = [NSApp runModalForWindow:nswindow];
|
||||
nswindow = nil;
|
||||
} else {
|
||||
clicked = [alert runModal];
|
||||
}
|
||||
}
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090
|
||||
- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
|
||||
{
|
||||
[NSApp stopModalWithCode:returnCode];
|
||||
}
|
||||
#endif
|
||||
@end
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user