fix github issue #400 - Qt text windows hanging

Text windows only accept a few keys (<escape>, <return>, ':', now
<space>) and if they got other keys they passed those up the call
chain, arriving at the map where they were treated as commands
and were executed while the text window was still displayed.  The
cited example was ',' for pickup while the "things that are here"
popup was shown.  The 'foreign' key's command might be executed
successfully but the undismissed popup could become hung.

This fixes that ('foreign' keys will be ignored).  It also lets
<space> be used to dismiss text windows.

Slightly better but far from perfect:  if you perform a search,
then after it runs you need to type <escape> once, or <return>
or <space> twice, or else search again and pick [done] on the
search popup and then <return> or <space> once, to dismiss a
text window via keyboard.  (Prior to this, typing <escape> or
searching again and picking [done] followed by <return> were the
only ways.)  Also, searching for an empty string will now be
treated as if [done] had been picked.

Fixes #400
This commit is contained in:
PatR
2021-01-14 15:10:41 -08:00
parent c131e6df18
commit 648162b536
2 changed files with 11 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.428 $ $NHDT-Date: 1610587460 2021/01/14 01:24:20 $
NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.429 $ $NHDT-Date: 1610665839 2021/01/14 23:10:39 $
General Fixes and Modified Features
-----------------------------------
@@ -596,6 +596,10 @@ Qt: there was no way to enter extended command "#version" by typing; command
name matching was waiting to disambiguate it from "#versionshort"
and the only way to that was to type #version<return> but <return>
explicitly triggered rejection, cancelling '#' processing
Qt: while a text window was shown (such as the "things that are here" popup
when stepping on items), typing commands had the input passed on to
the map and then executed; sometimes that caused the not-yet-dismissed
text window to hang
Qt: {maybe just Qt+OSX:} when viewing a text window ('V' to look at 'history'
for instance), clicking on [Search], entering a search target in the
resulting popup and clicking on [Okay] or typing <return>, the text

View File

@@ -1175,7 +1175,7 @@ void NetHackQtTextWindow::Search()
this->raise();
}
if (get_a_line) {
if (get_a_line && target[0]) {
int linecount = lines->count();
int current = lines->currentRow();
if (current == -1)
@@ -1215,13 +1215,16 @@ void NetHackQtTextWindow::keyPressEvent(QKeyEvent *key_event)
if (key == MENU_SEARCH) {
if (!use_rip)
Search();
} else if (key == '\n' || key == '\r') {
} else if (key == '\n' || key == '\r' || key == ' ') {
if (!textsearching)
accept();
else
textsearching = FALSE;
} else if (key == '\033') {
reject();
} else {
QDialog::keyPressEvent(key_event);
// ignore the current key instead of passing it along
//- QDialog::keyPressEvent(key_event);
}
}