Skip to content

Commit

Permalink
Fixed bug 2832 - Inverted arrow-key navigation in MessageBox
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
slouken committed Oct 7, 2016
1 parent 8bc5c57 commit dac3892
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/video/windows/SDL_windowsmessagebox.c
Expand Up @@ -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) {
Expand All @@ -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 */
Expand Down

0 comments on commit dac3892

Please sign in to comment.