Qt popup_dialog's count entry

For Qt with 'popup_dialog' On, fix number entry when user types
a digit (or '#') directly onto the dialog instead of clicking
inside the Count box and then typing.  Before, that first typed
digit was starting out as selected, so typing the next digit
replaced the selection instead of getting appended to the string
of digits being constructed.  Fixed by moving the relevant code
to the KeyPress handler instead of re-executing the dialog.

Also, if a keypress is just a modifier, ignore it.  The next
event should be the actual character.  Prevents treating <shift>
(and <caps lock>!) as useless dialog responses.  Before this,
attempting to type '#' to initiate a count wouldn't work because
the <shift> part of shift+3 ended the dialog.  Now '#' works
(and is still optional; starting with a digit suffices).
This commit is contained in:
PatR
2020-10-01 17:59:58 -07:00
parent 9045ccb63d
commit d1e1b0cdc9
4 changed files with 54 additions and 77 deletions

View File

@@ -956,7 +956,7 @@ void NetHackQtMainWindow::doQuit(bool)
case 0:
// quit -- bypass the prompting preformed by done2()
g.program_state.stopprint++;
done(QUIT);
::done(QUIT);
/*NOTREACHED*/
break;
case 1:
@@ -1260,7 +1260,7 @@ void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
// quit -- bypass the prompting preformed by done2()
ok = 1;
g.program_state.stopprint++;
done(QUIT);
::done(QUIT);
/*NOTREACHED*/
break;
}