Fixed bug 2832 - Inverted arrow-key navigation in MessageBox

Jan Hellwig

On Windows, you are able to navigate between the buttons on a MessageBox that was created using SDL_ShowMessageBox using the arrow keys. However, if you press the left arrow key, the selection jumps to the button on the right of the currently selected one (and vice versa).

This can be fixed by reversing the order in which the buttons are added to the dialog.

The attached patch files fixes this problem. However the first press of an arrow key leads to the selection of the leftmost or rightmost button on the MessageBox, not to the selection of the button left/right of the one that is selected by default.
This commit is contained in:
Sam Lantinga 2016-10-07 16:19:50 -07:00
parent 8bc5c57d2e
commit dac3892816

View File

@ -452,9 +452,9 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
}
/* Align the buttons to the right/bottom. */
x = Size.cx - ButtonWidth - ButtonMargin;
x = Size.cx - (ButtonWidth + ButtonMargin) * messageboxdata->numbuttons;
y = Size.cy - ButtonHeight - ButtonMargin;
for (i = 0; i < messageboxdata->numbuttons; ++i) {
for (i = messageboxdata->numbuttons - 1; i >= 0; --i) {
SDL_bool isDefault;
if (buttons[i].flags & SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT) {
@ -466,7 +466,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid)
FreeDialogData(dialog);
return -1;
}
x -= ButtonWidth + ButtonMargin;
x += ButtonWidth + ButtonMargin;
}
/* FIXME: If we have a parent window, get the Instance and HWND for them */