Qt: remove "Search [______]" from Help menu

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.
This commit is contained in:
PatR
2020-12-13 13:45:04 -08:00
parent c1b0f4e47a
commit 04724fc5a0
3 changed files with 24 additions and 7 deletions

View 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

View 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

View 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);
}