summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authormae <qt-info@nokia.com>2009-10-05 16:20:40 (GMT)
committermae <qt-info@nokia.com>2009-10-05 16:31:37 (GMT)
commitf38b88fa3d8ec4448c28044bf95c5c845a80d3f1 (patch)
tree78ae3ccc4a851d88dedbc5965068185b3e47fda9 /src/gui
parentb6313e00291a42e1e888a40b0c589ac5be497707 (diff)
downloadQt-f38b88fa3d8ec4448c28044bf95c5c845a80d3f1.zip
Qt-f38b88fa3d8ec4448c28044bf95c5c845a80d3f1.tar.gz
Qt-f38b88fa3d8ec4448c28044bf95c5c845a80d3f1.tar.bz2
Fix QPlainTextEdit 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 QPlainTextEdit. Reviewed-by: con
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/widgets/qplaintextedit.cpp51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp
index d519bfe..5d13c36 100644
--- a/src/gui/widgets/qplaintextedit.cpp
+++ b/src/gui/widgets/qplaintextedit.cpp
@@ -1578,7 +1578,35 @@ void QPlainTextEdit::keyPressEvent(QKeyEvent *e)
}
#endif
- if (!(d->control->textInteractionFlags() & Qt::TextEditable)) {
+#ifndef QT_NO_SHORTCUT
+
+ 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();
@@ -1605,27 +1633,6 @@ void QPlainTextEdit::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
-
-
d->sendControlEvent(e);
#ifdef QT_KEYPAD_NAVIGATION
if (!e->isAccepted()) {