diff --git a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp index 7cb023848..95e335963 100644 --- a/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp +++ b/cockatrice/src/interface/widgets/utility/line_edit_completer.cpp @@ -88,8 +88,7 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event) return; } - if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space || - event->key() == Qt::Key_Tab) { + if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space) { for (auto &info : completers) { if (info.completer->popup()->isVisible()) { event->ignore(); @@ -109,6 +108,27 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event) } } + if (event->key() == Qt::Key_Tab) { + for (auto &info : completers) { + if (info.completer->popup()->isVisible()) { + event->ignore(); + const QModelIndex currentIndex = info.completer->popup()->currentIndex(); + QString completionText; + if (currentIndex.isValid()) { + completionText = currentIndex.data().toString(); + } else { + completionText = info.completer->currentCompletion(); + } + if (!completionText.isEmpty()) { + insertCompletion(info.completer, completionText); + } + hideCompleterPopups(); + setFocus(); + return; + } + } + } + LineEditUnfocusable::keyPressEvent(event); QString textValue = text();