mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-05-03 20:44:42 +00:00
Fix bug where the wrong button was the default in the old message box because buttons were added backwards, breaking the indexing used by GetButtonIndex.
Add messagebox flags to explicilty request left-to-right button order or right-to-left. If neither is specified it'll be some platform default.
This commit is contained in:
@@ -75,13 +75,19 @@ WINRT_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
|
||||
MessageDialog ^ dialog = ref new MessageDialog(WINRT_UTF8ToPlatformString(messageboxdata->message));
|
||||
dialog->Title = WINRT_UTF8ToPlatformString(messageboxdata->title);
|
||||
for (int i = 0; i < messageboxdata->numbuttons; ++i) {
|
||||
UICommand ^ button = ref new UICommand(WINRT_UTF8ToPlatformString(messageboxdata->buttons[i].text));
|
||||
button->Id = safe_cast<IntPtr>(i);
|
||||
const SDL_MessageBoxButtonData *sdlButton;
|
||||
if (messageboxdata->flags & SDL_MESSAGEBOX_BUTTONS_RIGHT_TO_LEFT) {
|
||||
sdlButton = &messageboxdata->buttons[messageboxdata->numbuttons - 1 - i];
|
||||
} else {
|
||||
sdlButton = &messageboxdata->buttons[i];
|
||||
}
|
||||
UICommand ^ button = ref new UICommand(WINRT_UTF8ToPlatformString(sdlButton->text));
|
||||
button->Id = safe_cast<IntPtr>(sdlButton - messageboxdata->buttons);
|
||||
dialog->Commands->Append(button);
|
||||
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
||||
if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT) {
|
||||
dialog->CancelCommandIndex = i;
|
||||
}
|
||||
if (messageboxdata->buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||
if (sdlButton->flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
|
||||
dialog->DefaultCommandIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user