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:
Sam Lantinga
2019-08-02 17:19:50 -07:00
parent d52ffcf985
commit 63197c4338
8 changed files with 101 additions and 35 deletions

View File

@@ -2380,11 +2380,19 @@ int Android_JNI_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *bu
button_texts = (*env)->NewObjectArray(env, messageboxdata->numbuttons,
clazz, NULL);
for (i = 0; i < messageboxdata->numbuttons; ++i) {
temp = messageboxdata->buttons[i].flags;
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];
}
temp = sdlButton->flags;
(*env)->SetIntArrayRegion(env, button_flags, i, 1, &temp);
temp = messageboxdata->buttons[i].buttonid;
temp = sdlButton->buttonid;
(*env)->SetIntArrayRegion(env, button_ids, i, 1, &temp);
text = (*env)->NewStringUTF(env, messageboxdata->buttons[i].text);
text = (*env)->NewStringUTF(env, sdlButton->text);
(*env)->SetObjectArrayElement(env, button_texts, i, text);
(*env)->DeleteLocalRef(env, text);
}