From: PatR Date: Mon, 5 Oct 2020 23:26:27 +0000 (-0700) Subject: Qt menu search X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d7a52cf0c455ac2f66d4e11a1a4933e6e9620172;p=nethack Qt menu search Remove a 'TODO' for once. Have the popup that's used to accept the target string--after clicking on [search] or typing ':' to initiate menu search+select operation--force keyboard focus to itself. Menu searching worked without this, but only if you manually clicked on the search popup prior to typing the target string. Failure to do so resulted in typed characters being used to select menu entries. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 04e64186e..b68978a00 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.318 $ $NHDT-Date: 1601600393 2020/10/02 00:59:53 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.321 $ $NHDT-Date: 1601940384 2020/10/05 23:26:24 $ General Fixes and Modified Features ----------------------------------- @@ -430,6 +430,9 @@ Qt: 3.6 catchup - show unexplored locations as unexplored rather than as stone Qt: tried to honor 'showexp' but the value was unintentionally suppressed by [lack of definition for] obsolete conditional EXP_ON_BOTL Qt: implement --More-- prompt to support MSGTYPE=stop +Qt: for menu search, don't require clicking on the search target popup before + typing target string (was using typed letters to make menu selections + if player didn't click on the popup first) Qt+QSX: fix control key Qt+OSX: rename menu entry "nethack->Preferences..." for invoking nethack's 'O' command to "Game->Run-time options" and entry "Game->Qt settings" diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 1da9426d7..d2cf8eee1 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -6,8 +6,6 @@ // // TODO: -// search behaves weirdly unless you click in the line-edit dialog box -// after clicking on the [search] button to pop that up; // implement next_page, prev_page, first_page, and last_page to work // like they do for X11: scroll menu window as if it were paginated; // entering a count that uses more digits than the previous biggest count diff --git a/win/Qt/qt_streq.cpp b/win/Qt/qt_streq.cpp index b37ab305f..96133edec 100644 --- a/win/Qt/qt_streq.cpp +++ b/win/Qt/qt_streq.cpp @@ -83,6 +83,13 @@ bool NetHackQtStringRequestor::Get(char* buffer, int maxchar) #endif centerOnMain(this); show(); + // Make sure that setFocus() really does change keyboard focus. + // This allows typing to go directly to the NetHackQtLineEdit + // widget without clicking on or in it first. Not needed for + // qt_getline() but is needed for menu Search to prevent typed + // characters being treated as making menu selections. + if (!input.isActiveWindow()) + input.activateWindow(); input.setFocus(); exec();