diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-04-19 05:11:36 (GMT) |
---|---|---|
committer | Andrew den Exter <andrew.den-exter@nokia.com> | 2011-04-21 05:22:57 (GMT) |
commit | 60198a071dd76e57ab799215f0fbddc8d550ba30 (patch) | |
tree | f5801fea0958e2fb572e3a7de62ff6fe6e735c46 /src | |
parent | 2f173e4945dd8414636c1061acfaf9c2d8b718d8 (diff) | |
download | Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.zip Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.tar.gz Qt-60198a071dd76e57ab799215f0fbddc8d550ba30.tar.bz2 |
Fix TextInput cursor position unchanged when selection length is 0.
Move the cursor position to the start position when both the new and
old selections are empty as would happen if either was non-empty.
Change-Id: I493e52c551b47e009fd13b3e95856ff012ee5d95
Task-number: QTBUG-18768
Reviewed-by: Martin Jones
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/widgets/qlinecontrol.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/gui/widgets/qlinecontrol.cpp b/src/gui/widgets/qlinecontrol.cpp index d03e5de..202ea7a 100644 --- a/src/gui/widgets/qlinecontrol.cpp +++ b/src/gui/widgets/qlinecontrol.cpp @@ -254,12 +254,20 @@ void QLineControl::setSelection(int start, int length) m_selstart = start; m_selend = qMin(start + length, (int)m_text.length()); m_cursor = m_selend; - } else { + } else if (length < 0){ if (start == m_selend && start + length == m_selstart) return; m_selstart = qMax(start + length, 0); m_selend = start; m_cursor = m_selstart; + } else if (m_selstart != m_selend) { + m_selstart = 0; + m_selend = 0; + m_cursor = start; + } else { + m_cursor = start; + emitCursorPositionChanged(); + return; } emit selectionChanged(); emitCursorPositionChanged(); |