21#include "../../SDL_internal.h"
23#if SDL_VIDEO_DRIVER_UIKIT
34UIKit_ShowingMessageBox(
void)
36 return s_showingMessageBox;
40UIKit_WaitUntilMessageBoxClosed(
const SDL_MessageBoxData *messageboxdata,
int *clickedindex)
48 while ((*clickedindex) == messageboxdata->
numbuttons) {
49 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]];
56UIKit_ShowMessageBoxAlertController(
const SDL_MessageBoxData *messageboxdata,
int *buttonid)
59 int __block clickedindex = messageboxdata->
numbuttons;
62 UIWindow *alertwindow = nil;
64 if (![UIAlertController
class]) {
68 UIAlertController *alert;
69 alert = [UIAlertController alertControllerWithTitle:@(messageboxdata->title)
70 message:@(messageboxdata->message)
71 preferredStyle:UIAlertControllerStyleAlert];
74 UIAlertAction *action;
75 UIAlertActionStyle style = UIAlertActionStyleDefault;
78 style = UIAlertActionStyleCancel;
81 action = [UIAlertAction actionWithTitle:@(buttons[i].text)
83 handler:^(UIAlertAction *action) {
86 [alert addAction:action];
89 if (messageboxdata->
window) {
90 SDL_WindowData *data = (__bridge SDL_WindowData *) messageboxdata->window->driverdata;
91 window = data.uiwindow;
95 alertwindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
96 alertwindow.rootViewController = [UIViewController new];
97 alertwindow.windowLevel = UIWindowLevelAlert;
101 [alertwindow makeKeyAndVisible];
104 [
window.rootViewController presentViewController:alert animated:YES completion:nil];
105 UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
108 alertwindow.hidden = YES;
118#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
119@interface SDLAlertViewDelegate : NSObject <UIAlertViewDelegate>
121@property (nonatomic, assign)
int *clickedIndex;
125@implementation SDLAlertViewDelegate
127- (
void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
129 if (_clickedIndex !=
NULL) {
130 *_clickedIndex = (int) buttonIndex;
141#if __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
143 int clickedindex = messageboxdata->
numbuttons;
145 UIAlertView *alert = [[UIAlertView alloc] init];
146 SDLAlertViewDelegate *delegate = [[SDLAlertViewDelegate alloc] init];
148 alert.delegate = delegate;
149 alert.title = @(messageboxdata->
title);
150 alert.message = @(messageboxdata->
message);
153 [alert addButtonWithTitle:@(buttons[i].text)];
156 delegate.clickedIndex = &clickedindex;
160 UIKit_WaitUntilMessageBoxClosed(messageboxdata, &clickedindex);
162 alert.delegate = nil;
177 success = UIKit_ShowMessageBoxAlertController(messageboxdata, buttonid);
179 success = UIKit_ShowMessageBoxAlertView(messageboxdata, buttonid);
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
@ SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT
void UIKit_ForceUpdateHomeIndicator(void)
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)
EGLSurface EGLNativeWindowType * window
MessageBox structure containing title, text, window, etc.
const SDL_MessageBoxButtonData * buttons