Skip to content

Commit 29cb8b7

Browse files
committed
Windows: group accelerator and menu item collision
In the event that there is a collision between a menu group accelerator and an individual menu item's accelerator, disregard the group accelerator. '$' is the only known collision in NetHack 5.0 presently. Close #805
1 parent 9447bba commit 29cb8b7

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎win/win32/mhmenu.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef struct mswin_menu_item {
3535
int color;
3636
char str[NHMENU_STR_SIZE];
3737
boolean presel;
38+
boolean group_accelerator_collision;
3839
unsigned int itemflags;
3940
int count;
4041
BOOL has_focus;
@@ -191,7 +192,18 @@ mswin_menu_window_select_menu(HWND hWnd, int how, MENU_ITEM_P **_selected,
191192
/* collect group accelerators */
192193
for (i = 0; i < data->menui.menu.size; i++) {
193194
if (data->how != PICK_NONE) {
194-
if (data->menui.menu.items[i].group_accel
195+
/* Check for conflict between a specific selectable
196+
* menu item and its group accelerator.
197+
*/
198+
if (NHMENU_IS_SELECTABLE(data->menui.menu.items[i])
199+
&& data->menui.menu.items[i].group_accel
200+
== data->menui.menu.items[i].accelerator) {
201+
/* collision between specific menu item
202+
and its group accelerator */
203+
data->menui.menu.items[i].group_accelerator_collision = TRUE;
204+
}
205+
if (!data->menui.menu.items[i].group_accelerator_collision
206+
&& data->menui.menu.items[i].group_accel
195207
&& !strchr(data->menui.menu.gacc,
196208
data->menui.menu.items[i].group_accel)) {
197209
*ap++ = data->menui.menu.items[i].group_accel;
@@ -651,6 +663,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
651663
/* prevent & being interpreted as a mnemonic start */
652664
strNsubst(data->menui.menu.items[new_item].str, "&", "&&", 0);
653665
data->menui.menu.items[new_item].presel = msg_data->presel;
666+
data->menui.menu.items[new_item].group_accelerator_collision = FALSE;
654667
data->menui.menu.items[new_item].itemflags = msg_data->itemflags;
655668

656669
/* calculate tabstop size */

0 commit comments

Comments
 (0)