Fix wrong Backspace propagation.

This commit is contained in:
John Preston 2024-05-27 15:01:37 +04:00
parent ce3d2c5fb0
commit 951ccf4bb0

View file

@ -2936,7 +2936,9 @@ void InputField::keyPressEventInner(QKeyEvent *e) {
#endif // Q_OS_MAC #endif // Q_OS_MAC
} else { } else {
const auto text = e->text(); const auto text = e->text();
const auto oldPosition = textCursor().position(); const auto old = textCursor();
const auto oldPosition = old.position();
const auto oldSelection = old.hasSelection();
const auto oldModifiers = e->modifiers(); const auto oldModifiers = e->modifiers();
const auto allowedModifiers = (enter && ctrl) const auto allowedModifiers = (enter && ctrl)
? (~Qt::ControlModifier) ? (~Qt::ControlModifier)
@ -2960,7 +2962,10 @@ void InputField::keyPressEventInner(QKeyEvent *e) {
} else if (e->key() == Qt::Key_PageDown || e->key() == Qt::Key_Down) { } else if (e->key() == Qt::Key_PageDown || e->key() == Qt::Key_Down) {
cursor.movePosition(QTextCursor::End, e->modifiers().testFlag(Qt::ShiftModifier) ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor); cursor.movePosition(QTextCursor::End, e->modifiers().testFlag(Qt::ShiftModifier) ? QTextCursor::KeepAnchor : QTextCursor::MoveAnchor);
check = true; check = true;
} else if (e->key() == Qt::Key_Left || e->key() == Qt::Key_Right || e->key() == Qt::Key_Backspace) { } else if (!oldSelection
&& (e->key() == Qt::Key_Left
|| e->key() == Qt::Key_Right
|| e->key() == Qt::Key_Backspace)) {
e->ignore(); e->ignore();
} }
if (check) { if (check) {