diff options
author | Pekka Vuorela <pekka.ta.vuorela@nokia.com> | 2011-10-05 11:39:57 (GMT) |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-17 12:52:31 (GMT) |
commit | cd7aaa3820cb0b3ab777d1e8ae31379a1ef835e7 (patch) | |
tree | dd5d7e790182a79f27b9afb2fee22b832a352711 | |
parent | 84bfbd4cb090f7f77ae3b04308726d2b8ddf4792 (diff) | |
download | Qt-cd7aaa3820cb0b3ab777d1e8ae31379a1ef835e7.zip Qt-cd7aaa3820cb0b3ab777d1e8ae31379a1ef835e7.tar.gz Qt-cd7aaa3820cb0b3ab777d1e8ae31379a1ef835e7.tar.bz2 |
QSpinBox: fix cursor jumping around when pressing up/down keys
Backport of:
Make QLineEdit unit test pass again
Widget failed to update cursor position if selection remained the same, but
changed direction, and did not emit selectionChanged if change resulted
from input method event.
Bisected to fix
Task-number: QTBUG-15116
a regression introduced in fb7d86cf.
Change-Id: I6a4ae48d41efa5e126980749f89982f92e3ec499
Reviewed-by: Joona Petrell <joona.t.petrell@nokia.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
(cherry picked from qtbase/1189ebff320b8dd03637947c92df6e3ef84a3c06)
Reviewed-by: Mitch Curtis <mitch.curtis@digia.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index 6116e40..354a811 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -279,13 +279,13 @@ void QLineControl::setSelection(int start, int length) } if (length > 0) { - if (start == m_selstart && start + length == m_selend) + if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) return; m_selstart = start; m_selend = qMin(start + length, (int)m_text.length()); m_cursor = m_selend; } else if (length < 0){ - if (start == m_selend && start + length == m_selstart) + if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) return; m_selstart = qMax(start + length, 0); m_selend = start; @@ -451,6 +451,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) || event->preeditString() != preeditAreaText() || event->replacementLength() > 0; bool cursorPositionChanged = false; + bool selectionChange = false; if (isGettingInput) { // If any text is being input, remove selected text. @@ -494,6 +495,7 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) if (m_selend < m_selstart) { qSwap(m_selstart, m_selend); } + selectionChange = true; } else { m_selstart = m_selend = 0; } @@ -539,6 +541,8 @@ void QLineControl::processInputMethodEvent(QInputMethodEvent *event) emit updateMicroFocus(); if (isGettingInput) finishChange(priorState); + if (selectionChange) + emit selectionChanged(); } /*! @@ -626,7 +630,7 @@ void QLineControl::selectWordAtPos(int cursor) bool QLineControl::finishChange(int validateFromState, bool update, bool edited) { Q_UNUSED(update) - bool lineDirty = m_selDirty; + if (m_textDirty) { // do validation bool wasValidInput = m_validInput; @@ -657,7 +661,7 @@ bool QLineControl::finishChange(int validateFromState, bool update, bool edited) m_textDirty = false; } updateDisplayText(); - lineDirty |= m_textDirty; + if (m_textDirty) { m_textDirty = false; QString actualText = text(); |