21 #include "../../SDL_internal.h" 23 #if SDL_VIDEO_DRIVER_COCOA 30 @interface SDLMessageBoxPresenter : NSObject {
36 - (
void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(
void *)contextInfo;
39 @implementation SDLMessageBoxPresenter
57 - (
void)showAlert:(NSAlert*)alert
60 [alert beginSheetModalForWindow:nswindow modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil];
67 clicked = [alert runModal];
71 - (
void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(
void *)contextInfo
86 NSAlert* alert = [[[NSAlert alloc] init] autorelease];
89 [alert setAlertStyle:NSCriticalAlertStyle];
91 [alert setAlertStyle:NSWarningAlertStyle];
93 [alert setAlertStyle:NSInformationalAlertStyle];
96 [alert setMessageText:[NSString stringWithUTF8String:messageboxdata->title]];
97 [alert setInformativeText:[NSString stringWithUTF8String:messageboxdata->message]];
101 for (i = 0; i < messageboxdata->
numbuttons; ++i) {
102 NSButton *
button = [alert addButtonWithTitle:[NSString stringWithUTF8String:buttons[i].text]];
104 [button setKeyEquivalent:@"\r"];
106 [button setKeyEquivalent:@"\033"];
108 [button setKeyEquivalent:@""];
112 SDLMessageBoxPresenter* presenter = [[[SDLMessageBoxPresenter alloc] initWithParentWindow:messageboxdata->window] autorelease];
114 [presenter performSelectorOnMainThread:@selector(showAlert:)
119 NSInteger clicked = presenter->clicked;
120 if (clicked >= NSAlertFirstButtonReturn) {
121 clicked -= NSAlertFirstButtonReturn;
122 *buttonid = buttons[clicked].
buttonid;
124 returnValue =
SDL_SetError(
"Did not get a valid `clicked button' id: %ld", (
long)clicked);
void Cocoa_RegisterApp(void)
const SDL_MessageBoxButtonData * buttons
MessageBox structure containing title, text, window, etc.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
The type used to identify a window.