From 71decafefde7b22551df169b0caa8f495a11485d Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 21 Apr 2023 00:44:50 -0700 Subject: [PATCH] Qt menu fix Noticed when working on the add_menu() crash earlier, using a mouse rather than the keyboard to pick an entry in the sub-sub menus for 'm O' -> 'disclose' -> {any disclosure category} didn't work properly. The problem was in post-3.6.x menu code for the Qt interface. --- doc/fixes3-7-0.txt | 5 +++++ win/Qt/qt_menu.cpp | 2 +- win/Qt/qt_win.h | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 85de14c5a..22b24519c 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1583,6 +1583,11 @@ Qt: changes in glyph handling in the core introduced a bug in the "paper doll" Qt: during role selection, icons for role and race showed giant ant tile after the glyph overhaul changes Qt: resolve a use-after-free error when saving message history +Qt: with a pick-one menu containing a pre-selected entry, clicking on that + worked to re-select it, as intended; clicking on any other entry + instead of typing the selector letter toggled off preselected entry + but failed to toggle on the explicitly selected one; clicking again + after nothing was pre-selected anymore refused to toggle anything on tty: redraw unexplored locations as S_unexplored rather than after map has been partially overwritten by popup menu or text display tty: previous change resulted in remnants of previous level being shown on diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 441113189..e2ff8664e 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -802,7 +802,7 @@ void NetHackQtMenuWindow::ChooseNone() itemlist[row].preselected = false; // stale for all rows // skip if not selectable or already unselected or fails invert_test() if (!itemlist[row].Selectable() - || !itemlist[row].selected + || (!itemlist[row].selected && !isSelected(row)) || !menuitem_invert_test(2, itemlist[row].itemflags, TRUE)) continue; itemlist[row].selected = false; diff --git a/win/Qt/qt_win.h b/win/Qt/qt_win.h index adc05f63d..ffc10efea 100644 --- a/win/Qt/qt_win.h +++ b/win/Qt/qt_win.h @@ -42,7 +42,8 @@ public: virtual void EndMenu(const QString& prompt); virtual int SelectMenu(int how, MENU_ITEM_P **menu_list); virtual void ClipAround(int x, int y); - virtual void PrintGlyph(int x, int y, const glyph_info *glyphinfo, const glyph_info *bkglyphinfo); + virtual void PrintGlyph(int x, int y, const glyph_info *glyphinfo, + const glyph_info *bkglyphinfo); virtual void UseRIP(int how, time_t when); int nhid;