mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[UI] Fix auto-completion acceptance on Space/Tab/Enter
This commit is contained in:
parent
bb61617d42
commit
1836160538
1 changed files with 23 additions and 3 deletions
|
|
@ -72,13 +72,33 @@ void LineEditCompleter::focusOutEvent(QFocusEvent *e)
|
|||
|
||||
void LineEditCompleter::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
LineEditUnfocusable::keyPressEvent(event);
|
||||
|
||||
if (event->key() == Qt::Key_Escape) {
|
||||
hideCompleterPopups();
|
||||
if (hasVisibleCompleterPopup()) {
|
||||
event->ignore();
|
||||
hideCompleterPopups();
|
||||
return;
|
||||
}
|
||||
LineEditUnfocusable::keyPressEvent(event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space ||
|
||||
event->key() == Qt::Key_Tab) {
|
||||
for (auto &info : completers) {
|
||||
if (info.completer->popup()->isVisible()) {
|
||||
event->ignore();
|
||||
const QModelIndex currentIndex = info.completer->popup()->currentIndex();
|
||||
if (currentIndex.isValid()) {
|
||||
insertCompletion(info.completer, currentIndex.data().toString());
|
||||
}
|
||||
hideCompleterPopups();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LineEditUnfocusable::keyPressEvent(event);
|
||||
|
||||
QString textValue = text();
|
||||
int cursorPos = cursorPosition();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue