Skip to content
Permalink
Browse files

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.
  • Loading branch information
slouken committed Oct 7, 2016
1 parent 8bc5c57 commit dac3892816a544b1f5130d3ec09368e3f2b99698
Showing with 3 additions and 3 deletions.
  1. +3 −3 src/video/windows/SDL_windowsmessagebox.c
@@ -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 */

0 comments on commit dac3892

Please sign in to comment.