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 <Friedemann.Kleint@nokia.com>
(cherry picked from commit 054fa68b6ae852e84f2d44a73260b4282286f5ab)
Change-Id: I054fa68b6ae852e84f2d44a73260b4282286f5ab
This commit is contained in:
jahonkon 2011-11-11 10:59:47 +01:00 committed by Qt by Nokia
parent 61fae7e551
commit fd3d7429b2
2 changed files with 3 additions and 6 deletions

View File

@ -1918,10 +1918,7 @@ void QTextControlPrivate::focusEvent(QFocusEvent *e)
if (!QGuiApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason if (!QGuiApplication::keypadNavigationEnabled() || (hasEditFocus && (e->reason() == Qt::PopupFocusReason
))) { ))) {
#endif #endif
cursorOn = (interactionFlags & Qt::TextSelectableByKeyboard); setBlinkingCursorEnabled(interactionFlags & (Qt::TextEditable | Qt::TextSelectableByKeyboard));
if (interactionFlags & Qt::TextEditable) {
setBlinkingCursorEnabled(true);
}
#ifdef QT_KEYPAD_NAVIGATION #ifdef QT_KEYPAD_NAVIGATION
} }
#endif #endif
@ -2586,7 +2583,7 @@ void QTextControl::setTextInteractionFlags(Qt::TextInteractionFlags flags)
d->interactionFlags = flags; d->interactionFlags = flags;
if (d->hasFocus) if (d->hasFocus)
d->setBlinkingCursorEnabled(flags & Qt::TextEditable); d->setBlinkingCursorEnabled(flags & (Qt::TextEditable | Qt::TextSelectableByKeyboard));
} }
Qt::TextInteractionFlags QTextControl::textInteractionFlags() const Qt::TextInteractionFlags QTextControl::textInteractionFlags() const

View File

@ -1899,7 +1899,7 @@ void QPlainTextEdit::paintEvent(QPaintEvent *e)
} }
} }
bool drawCursor = (editable bool drawCursor = ((editable || (textInteractionFlags() & Qt::TextSelectableByKeyboard))
&& context.cursorPosition >= blpos && context.cursorPosition >= blpos
&& context.cursorPosition < blpos + bllen); && context.cursorPosition < blpos + bllen);