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.
This commit is contained in:
PatR
2020-10-05 16:26:27 -07:00
parent 37339abebd
commit d7a52cf0c4
3 changed files with 11 additions and 3 deletions

View File

@@ -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();