diff options
author | Paul Olav Tvete <paul.tvete@digia.com> | 2013-04-26 17:25:57 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-04-30 15:15:30 +0200 |
commit | 798112b6532a3c66abff630327d29a980a525f25 (patch) | |
tree | 20974e2d82909515469c30af7f3fd7288fb06c48 /src | |
parent | 83acf00567af0c028e095b89e356c2927f5e4b2f (diff) |
Don't eat Back button in TextEdit
On Android, Key_Back is used to change to the previous state in-app,
as well as to exit the application. QTextControl does not react to the
back button, so it should not accept the event.
Task-number: QTBUG-30752
Change-Id: I010d36c93f14384b96fb0b2f0015c57a2a3d2497
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@digia.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquicktextcontrol.cpp | 19 | ||||
-rw-r--r-- | src/quick/items/qquicktextcontrol_p_p.h | 1 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/quick/items/qquicktextcontrol.cpp b/src/quick/items/qquicktextcontrol.cpp index 9625aa5d5e..d0c4aad64b 100644 --- a/src/quick/items/qquicktextcontrol.cpp +++ b/src/quick/items/qquicktextcontrol.cpp @@ -698,6 +698,9 @@ void QQuickTextControl::processEvent(QEvent *e, const QMatrix &matrix) case QEvent::KeyPress: d->keyPressEvent(static_cast<QKeyEvent *>(e)); break; + case QEvent::KeyRelease: + d->keyReleaseEvent(static_cast<QKeyEvent *>(e)); + break; case QEvent::MouseButtonPress: { QMouseEvent *ev = static_cast<QMouseEvent *>(e); d->mousePressEvent(ev, matrix.map(ev->localPos())); @@ -809,9 +812,25 @@ void QQuickTextControl::setHtml(const QString &text) d->setContent(Qt::RichText, text); } + +void QQuickTextControlPrivate::keyReleaseEvent(QKeyEvent *e) +{ + if (e->key() == Qt::Key_Back) { + e->ignore(); + return; + } + return; +} + void QQuickTextControlPrivate::keyPressEvent(QKeyEvent *e) { Q_Q(QQuickTextControl); + + if (e->key() == Qt::Key_Back) { + e->ignore(); + return; + } + #ifndef QT_NO_SHORTCUT if (e == QKeySequence::SelectAll) { e->accept(); diff --git a/src/quick/items/qquicktextcontrol_p_p.h b/src/quick/items/qquicktextcontrol_p_p.h index fbb88bd255..da76de8ffe 100644 --- a/src/quick/items/qquicktextcontrol_p_p.h +++ b/src/quick/items/qquicktextcontrol_p_p.h @@ -108,6 +108,7 @@ public: QRectF rectForPosition(int position) const; void keyPressEvent(QKeyEvent *e); + void keyReleaseEvent(QKeyEvent *e); void mousePressEvent(QMouseEvent *event, const QPointF &pos); void mouseMoveEvent(QMouseEvent *event, const QPointF &pos); void mouseReleaseEvent(QMouseEvent *event, const QPointF &pos); |