diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-03-14 00:47:36 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-03-14 01:58:50 (GMT) |
commit | a1a9929acaeccd7027605ffeb9794b034b146c92 (patch) | |
tree | 31ef36403bcc0494d1e42b2ef006c6197d22112a /src/gui/text/qtextcontrol.cpp | |
parent | c422ed3b861ab92276c91a6672b313f037de6ff6 (diff) | |
download | Qt-a1a9929acaeccd7027605ffeb9794b034b146c92.zip Qt-a1a9929acaeccd7027605ffeb9794b034b146c92.tar.gz Qt-a1a9929acaeccd7027605ffeb9794b034b146c92.tar.bz2 |
Fix TextEdit mouseSelectionMode overriding selectByMouse.
If selectByMouse is false don't allow any text selection on mouse
move.
Change-Id: Ic9f309899bc0de48066a2393e088e15b3a2f06db
Task-number: QTBUG-18072
Reviewed-by: Martin Jones
Diffstat (limited to 'src/gui/text/qtextcontrol.cpp')
-rw-r--r-- | src/gui/text/qtextcontrol.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/gui/text/qtextcontrol.cpp b/src/gui/text/qtextcontrol.cpp index f5da079..6babca1 100644 --- a/src/gui/text/qtextcontrol.cpp +++ b/src/gui/text/qtextcontrol.cpp @@ -1607,7 +1607,10 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons if (!(buttons & Qt::LeftButton)) return; - if (!((interactionFlags & Qt::TextSelectableByMouse) || (interactionFlags & Qt::TextEditable))) + const bool selectable = interactionFlags & Qt::TextSelectableByMouse; + const bool editable = interactionFlags & Qt::TextEditable; + + if (!selectable && !editable) return; if (!(mousePressed @@ -1623,6 +1626,10 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons startDrag(); return; } + + if (!selectable) + return; + const qreal mouseX = qreal(mousePos.x()); int newCursorPos = q->hitTest(mousePos, Qt::FuzzyHit); @@ -1638,7 +1645,7 @@ void QTextControlPrivate::mouseMoveEvent(QEvent *e, Qt::MouseButton button, cons extendBlockwiseSelection(newCursorPos); else if (selectedWordOnDoubleClick.hasSelection()) extendWordwiseSelection(newCursorPos, mouseX); - else if (interactionFlags & Qt::TextSelectableByMouse) + else setCursorPosition(newCursorPos, QTextCursor::KeepAnchor); if (interactionFlags & Qt::TextEditable) { |