mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-10-01 07:28:30 +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:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user