From fd3d7429b2b00fe2e3f8ca7b41a04273b42077e8 Mon Sep 17 00:00:00 2001 From: jahonkon Date: Fri, 11 Nov 2011 10:59:47 +0100 Subject: Fix QPlainTextEdit when using Qt::TextSelectableByKeyboard flag It is not possible to select text with keyboard when specifying only Qt::TextSelectableByKeyboard flag. Task-number: QTBUG-18952 Reviewed-by: Friedemann Kleint (cherry picked from commit 054fa68b6ae852e84f2d44a73260b4282286f5ab) Change-Id: I054fa68b6ae852e84f2d44a73260b4282286f5ab --- src/gui/text/qtextcontrol.cpp | 7 ++----- src/widgets/widgets/qplaintextedit.cpp | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index 44aa2b9120..f74d67cf6d 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1918,10 +1918,7 @@ void QTextControlPrivate::focusEvent(QFocusEvent *e) if (!QGuiApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason ))) { #endif - cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard); - if (interactionFlags & Qt::TextEditable) { - setBlinkingCursorEnabled(true); - } + setBlinkingCursorEnabled(interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard)); #ifdef QT_KEYPAD_NAVIGATION } #endif @@ -2586,7 +2583,7 @@ void QTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags) d->interactionFlags = flags; if (d->hasFocus) - d->setBlinkingCursorEnabled(flags & Qt::TextEditable); + d->setBlinkingCursorEnabled(flags & (Qt::TextEditable | Qt::TextSelectableByKeyboard)); } Qt::TextInteractionFlags QTextControl::textInteractionFlags() const diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp index 8a6ac67989..98a8999a98 100644 --- a/src/widgets/widgets/qplaintextedit.cpp +++ b/src/widgets/widgets/qplaintextedit.cpp @@ -1899,7 +1899,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e) } } - bool drawCursor = (editable + bool drawCursor = ((editable || (textInteractionFlags() & Qt::TextSelectableByKeyboard)) && context.cursorPosition >= blpos && context.cursorPosition < blpos + bllen); -- cgit v1.2.3