#================================================================================================== # libsdl2 v2.28.0 - Revert changes for issue: https://github.com/libsdl-org/SDL/issues/6948 # # Necessary to fix builds for 10.8 and earlier #================================================================================================== --- src/video/cocoa/SDL_cocoamessagebox.m +++ src/video/cocoa/SDL_cocoamessagebox.m @@ -32,7 +32,8 @@ NSInteger clicked; NSWindow *nswindow; } -- (id)initWithParentWindow:(SDL_Window *)window; +- (id) initWithParentWindow:(SDL_Window *)window; +- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo; @end @implementation SDLMessageBoxPresenter @@ -56,16 +57,35 @@ - (void)showAlert:(NSAlert*)alert { if (nswindow) { - [alert beginSheetModalForWindow:nswindow - completionHandler:^(NSModalResponse returnCode) { - [NSApp stopModalWithCode:returnCode]; - }]; - clicked = [NSApp runModalForWindow:nswindow]; +#ifdef MAC_OS_X_VERSION_10_9 + if ([alert respondsToSelector:@selector(beginSheetModalForWindow:completionHandler:)]) { + [alert beginSheetModalForWindow:nswindow completionHandler:^(NSModalResponse returnCode) { + self->clicked = returnCode; + }]; + } else +#endif + { +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 + [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil]; +#endif + } + + while (clicked < 0) { + SDL_PumpEvents(); + SDL_Delay(100); + } + nswindow = nil; } else { clicked = [alert runModal]; } } + +- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo +{ + clicked = returnCode; +} + @end