From: Alex Kompel Date: Tue, 12 Jan 2016 04:54:59 +0000 (-0800) Subject: win32_gui: cycle accelerator letters on large menues X-Git-Tag: NetHack-3.6.1_RC01~1024^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=da95cccc445ef02222ba176b3512e26271438aa4;p=nethack win32_gui: cycle accelerator letters on large menues --- diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index 2a65afc85..e7519a69e 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -169,7 +169,7 @@ mswin_menu_window_select_menu(HWND hWnd, int how, MENU_ITEM_P **_selected, if (next_char > 'z') next_char = 'A'; else if (next_char > 'Z') - break; + next_char = 'a'; data->menu.items[i].accelerator = next_char; } @@ -1441,7 +1441,11 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch) if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') || is_accelerator) { if (data->how == PICK_ANY || data->how == PICK_ONE) { - for (i = 0; i < data->menu.size; i++) { + topIndex = ListView_GetTopIndex(hwndList); + if( topIndex < 0 || topIndex > data->menu.size ) break; // impossible? + int iter = topIndex; + do { + i = iter % data->menu.size; if (data->menu.items[i].accelerator == ch) { if (data->how == PICK_ANY) { SelectMenuItem( @@ -1459,7 +1463,7 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch) return -2; } } - } + } while( (++iter % data->menu.size) != topIndex ); } } break;