mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[UI] Keep focus in chat on Tab completion acceptance
This commit is contained in:
parent
b8b04f9a7a
commit
7b8d86f45a
1 changed files with 22 additions and 2 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue