From: PatR Date: Thu, 17 Dec 2020 21:55:10 +0000 (-0800) Subject: Qt text window search X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee9fa9ebe365e184a6b8247a27a838c4860ca346;p=nethack 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. --- diff --git a/win/Qt/qt_menu.cpp b/win/Qt/qt_menu.cpp index 1a549a8e0..e02cd3d40 100644 --- a/win/Qt/qt_menu.cpp +++ b/win/Qt/qt_menu.cpp @@ -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();