From 2a1adf71ab3dc748e79aa6b76ff1d40c7db77c67 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 5 Aug 2019 23:52:16 -0700 Subject: [PATCH] Fixed bug 4747 - [Patch] SDL_ShowMessageBox ignores BUTTON_RETURNKEY_DEFAULT flag Caleb Cornett SDL_ShowMessageBox on UIKit doesn't do anything special with buttons that are marked with the flag SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT. According to Apple's documentation on UIAlertController, a button can respond to a return key if it's marked as the preferredAction of the controller. SDL doesn't set a preferredAction currently, so I've attached a patch to fix that. --- src/video/uikit/SDL_uikitmessagebox.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/uikit/SDL_uikitmessagebox.m b/src/video/uikit/SDL_uikitmessagebox.m index 7480f645c8161..defb4d682842f 100644 --- a/src/video/uikit/SDL_uikitmessagebox.m +++ b/src/video/uikit/SDL_uikitmessagebox.m @@ -91,6 +91,10 @@ clickedindex = (int)(sdlButton - messageboxdata->buttons); }]; [alert addAction:action]; + + if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) { + alert.preferredAction = action; + } } if (messageboxdata->window) {