]> granicus.if.org Git - nethack/commitdiff
Qt: remove "Search [______]" from Help menu
authorPatR <rankin@nethack.org>
Sun, 13 Dec 2020 21:45:04 +0000 (13:45 -0800)
committerPatR <rankin@nethack.org>
Sun, 13 Dec 2020 21:45:04 +0000 (13:45 -0800)
Prevent Qt from inserting an extra entry in the Help dropdown
menu displayed in the menu bar across the top of the screen
when nethack has focus.  "Search [______]" lets the user enter
a string to search for but doesn't give nethack any control
over that so we can't have it.

I haven't found a sane way to get rid of it.  The insane way
of not naming any menu "Help" works.  This uses "\177Help" so
that it still looks like "Help" but won't match that string.

doc/fixes37.0
win/Qt/Qt-issues.txt
win/Qt/qt_main.cpp

index 01ae61a10987673d1b19c6dc5d3eb3f4b1a7b01f..2ead283a6336ce58f21b5b0368151f27a624f66d 100644 (file)
@@ -1,4 +1,4 @@
-NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.386 $ $NHDT-Date: 1607754748 2020/12/12 06:32:28 $
+NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.390 $ $NHDT-Date: 1607895902 2020/12/13 21:45:02 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -551,6 +551,8 @@ Qt+OSX: add a separate nethack->Quit menu entry with different functionality;
 Qt+OSX: since menu entry help->"About Qt NetHack" gets hijacked and becomes
        "nethack->About nethack", add a separate help->_About_Qt_NetHack_
        which stays where intended and brings up the same information
+Qt+OSX: suppress unwanted "Search [______]" action from being inserted as the
+       first entry in the menubar's "Help" dropdown menu
 tiles: add indicator of thonged portion to aklys tile
 tty: role and race selection menus weren't filtering out potential choices
        which got excluded by OPTIONS=align:!lawful or !neutral or !chaotic
index 98c4621a6a4a80dcc851f283445e8492abca88ac..c38fca66192e065c1a14826b947d9289eebb237c 100644 (file)
@@ -26,12 +26,6 @@ around by giving focus to some other application (which will put up
 its own menu bar) and then back to nethack (thereby reloading nethack's
 menu bar).
 
-On OSX, a "Search [______]" action is inserted as the first entry of
-the dropdown Help menu on the toolbar.  NetHack has no control over
-what it does or where it looks, so it should be eliminated somehow.
-(It is not releated to nethack's search command, nor the interception
-of an attempt to insert "Search" into the dropdown Action menu.)
-
 Sometimes scrolling a menu leaves the displayed text not matching what
 nethack thinks is displayed, so making a selection by mouse click may
 occasionally pick the wrong item.  There's usually a visual clue when
index a8bbebed8dfff20ef3970b90ea528855d403fbd4..eb6cd8af9ed95ea88dc72ec2daf4231aa5c1fea6 100644 (file)
@@ -781,7 +781,28 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
        info->setTitle("Info");
        menubar->addMenu(info);
        menubar->addSeparator();
+#ifndef MACOSX
        help->setTitle("Help");
+#else
+        // On OSX, an entry in the menubar called "Help" will get an
+        // extra action, "Search [______]", inserted as the first entry.
+        // We have no control over what it does and don't want it.
+        //
+        // Using actions() to fetch a list of all entries doesn't find it,
+        // so we don't have its widget pointer to pass to removeAction().
+        //
+        // Altering the name with an invisible character to inhibit
+        // string matching is ludicrous but keeps the unwanted action
+        // from getting inserted into the "Help" menu behind our back.
+        // Underscore works too and is more robust but unless we prepend
+        // it to every entry, "_Help" would stand out as strange.
+       help->setTitle("\177Help");
+        // (Renaming back to "Help" after the fact does reset the menu's
+        // name but it also results in the Search action being added.
+        // Perhaps a custom context menu that changes its name to "Help"
+        // as it is being shown--and possibly changes back afterward--
+        // would work but the name mangling hack is much simpler.)
+#endif
        menubar->addMenu(help);
     }