Qt text window search

Fix the strangeness where typing ':' in a menu window initiated
the menu search operation but typing ':' in a text window saw
the shift key be pressed but not the ';' that went with it, even
though they both called the same key decoding routine.  That made
typing ':' to initiate text search be impossible.  Menu windows
did more input focus manipulation in their constructor.  Mimicking
that in text windows fixes the problem with keys not being seen by
the text window's keystroke handler.
This commit is contained in:
PatR
2020-12-17 13:55:10 -08:00
parent 65763f9bec
commit ee9fa9ebe3

View File

@@ -999,6 +999,8 @@ NetHackQtTextWindow::NetHackQtTextWindow(QWidget *parent) :
// we don't want keystrokes being sent to the main window for use as
// commands while this text window is popped up
setFocusPolicy(Qt::StrongFocus);
// needed so that keystrokes get sent to our keyPressEvent()
lines->setFocusPolicy(Qt::NoFocus);
}
void NetHackQtTextWindow::doUpdate()
@@ -1183,11 +1185,12 @@ void NetHackQtTextWindow::Search()
// Force text window to be on top. Without this, it moves behind
// the map after the string requestor completes. Then it can't
// be seen or accessed (unless the game window is minimized or
// possibly dragged out of the way). Unfortunately the window
// noticeably vanishes and then immediately gets redrawn.
if (!this->isActiveWindow())
// dragged out of the way). Unfortunately the window noticeably
// vanishes and then immediately gets redrawn.
if (!this->isActiveWindow()) {
this->activateWindow();
this->raise();
this->raise();
}
if (get_a_line) {
int linecount = lines->count();
@@ -1226,12 +1229,6 @@ void NetHackQtTextWindow::keyPressEvent(QKeyEvent *key_event)
{
uchar key = keyValue(key_event);
//
// FIXME:
// Typing ':' doesn't produce ':' so key won't match MENU_SEARCH,
// despite the fact that it does produce ':' for menu input and
// we're calling the exact same code for both types of window...?
//
if (key == MENU_SEARCH) {
if (!use_rip)
Search();