diff options
author | mae <qt-info@nokia.com> | 2009-10-05 16:30:35 (GMT) |
---|---|---|
committer | mae <qt-info@nokia.com> | 2009-10-05 16:31:37 (GMT) |
commit | 45cd658c7dce650b12e2d0760e852ece1d8812fd (patch) | |
tree | cc4694a7372d311dd14943afeab4694e235ca9bd /src/gui/widgets | |
parent | f38b88fa3d8ec4448c28044bf95c5c845a80d3f1 (diff) | |
download | Qt-45cd658c7dce650b12e2d0760e852ece1d8812fd.zip Qt-45cd658c7dce650b12e2d0760e852ece1d8812fd.tar.gz Qt-45cd658c7dce650b12e2d0760e852ece1d8812fd.tar.bz2 |
Fix QTextEdit pageUp/Down key handling in read-only mode
QTextControl has two independent interaction flags
TextEditable and TextSelectableByKeyboard, i.e. the latter can also
apply in read-only mode. This used to be handled incorrectly
in QTextEdit.
Reviewed-by: con
Diffstat (limited to 'src/gui/widgets')
-rw-r--r-- | src/gui/widgets/qtextedit.cpp | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index dc78fd5..b894aa8 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -1220,8 +1220,35 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) break; } #endif +#ifndef QT_NO_SHORTCUT - if (!(d->control->textInteractionFlags() & Qt::TextEditable)) { + Qt::TextInteractionFlags tif = d->control->textInteractionFlags(); + + if (tif & Qt::TextSelectableByKeyboard){ + if (e == QKeySequence::SelectPreviousPage) { + e->accept(); + d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); + return; + } else if (e ==QKeySequence::SelectNextPage) { + e->accept(); + d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); + return; + } + } + if (tif & (Qt::TextSelectableByKeyboard | Qt::TextEditable)) { + if (e == QKeySequence::MoveToPreviousPage) { + e->accept(); + d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); + return; + } else if (e == QKeySequence::MoveToNextPage) { + e->accept(); + d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); + return; + } + } +#endif // QT_NO_SHORTCUT + + if (!(tif & Qt::TextEditable)) { switch (e->key()) { case Qt::Key_Space: e->accept(); @@ -1248,26 +1275,6 @@ void QTextEdit::keyPressEvent(QKeyEvent *e) return; } -#ifndef QT_NO_SHORTCUT - if (e == QKeySequence::MoveToPreviousPage) { - e->accept(); - d->pageUpDown(QTextCursor::Up, QTextCursor::MoveAnchor); - return; - } else if (e == QKeySequence::MoveToNextPage) { - e->accept(); - d->pageUpDown(QTextCursor::Down, QTextCursor::MoveAnchor); - return; - } else if (e == QKeySequence::SelectPreviousPage) { - e->accept(); - d->pageUpDown(QTextCursor::Up, QTextCursor::KeepAnchor); - return; - } else if (e ==QKeySequence::SelectNextPage) { - e->accept(); - d->pageUpDown(QTextCursor::Down, QTextCursor::KeepAnchor); - return; - } -#endif // QT_NO_SHORTCUT - { QTextCursor cursor = d->control->textCursor(); const QString text = e->text(); |