]> granicus.if.org Git - nethack/commitdiff
Fix for bug H7132.
authorBart House <bart@barthouse.com>
Tue, 8 May 2018 14:25:24 +0000 (07:25 -0700)
committerBart House <bart@barthouse.com>
Tue, 8 May 2018 14:25:24 +0000 (07:25 -0700)
In nethackw, there can be conflicts between menu accelerators and an extra
choice accelerator.  For example, when engraving the using fingers options
conflicts with the unselect all menu accelerator.  The extra choice
accelerator should take precedence.

win/win32/mhmenu.c

index b541af3056bfbe52b6a396e0850234e69103c549..c8d71b4e6131b2a15936bcc67c07d54d2834316e 100644 (file)
@@ -1208,6 +1208,21 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch)
 
     data = (PNHMenuWindow) GetWindowLongPtr(hWnd, GWLP_USERDATA);
 
+    is_accelerator = FALSE;
+    for (i = 0; i < data->menu.size; i++) {
+        if (data->menu.items[i].accelerator == ch) {
+            is_accelerator = TRUE;
+            break;
+        }
+    }
+
+    /* Don't use switch if input matched an accelerator.  Sometimes
+     * accelerators can conflict with menu actions.  For example, when
+     * engraving the extra choice of using fingers matches MENU_UNSELECT_ALL.
+     */
+    if (is_accelerator)
+        goto accelerator;
+
     switch (ch) {
     case MENU_FIRST_PAGE:
         i = 0;
@@ -1402,6 +1417,7 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch)
         }
     } break;
 
+    accelerator:
     default:
         if (strchr(data->menu.gacc, ch)
             && !(ch == '0' && data->menu.counting)) {
@@ -1450,14 +1466,6 @@ onListChar(HWND hWnd, HWND hwndList, WORD ch)
             return -2;
         }
 
-        is_accelerator = FALSE;
-        for (i = 0; i < data->menu.size; i++) {
-            if (data->menu.items[i].accelerator == ch) {
-                is_accelerator = TRUE;
-                break;
-            }
-        }
-
         if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z')
             || is_accelerator) {
             if (data->how == PICK_ANY || data->how == PICK_ONE) {