summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@digia.com>2014-05-23 14:39:53 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-05-26 15:06:12 +0200
commitb732e56969940a9c3bbb1b4e09d671005e4a1006 (patch)
treee63cce4ecaea803bc4f9c9690d55d22009695c5c /src
parent262d2cba12e9b164f9699951b37def21e1ed1652 (diff)
Android: Report current selection to the input method
Task-number: QTBUG-39196 Change-Id: Ib798f1de83ccbe3830a746b6ddd435a0934c34cd Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/platforms/android/qandroidinputcontext.cpp20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp
index c2e5f83639..5d47d2fda4 100644
--- a/src/plugins/platforms/android/qandroidinputcontext.cpp
+++ b/src/plugins/platforms/android/qandroidinputcontext.cpp
@@ -472,12 +472,24 @@ void QAndroidInputContext::updateCursorPosition()
if (m_composingText.isEmpty() != (m_composingTextStart == -1))
qWarning() << "Input method out of sync" << m_composingText << m_composingTextStart;
-
- // Qt's idea of the cursor position is the start of the preedit area, so we have to maintain our own preedit cursor pos
int realCursorPosition = cursorPos;
+ int realAnchorPosition = cursorPos;
+
+ int cpos = query->value(Qt::ImCursorPosition).toInt();
+ int anchor = query->value(Qt::ImAnchorPosition).toInt();
+ if (cpos != anchor) {
+ if (!m_composingText.isEmpty()) {
+ qWarning("Selecting text while preediting may give unpredictable results.");
+ finishComposingText();
+ }
+ int blockPos = getBlockPosition(query);
+ realCursorPosition = blockPos + cpos;
+ realAnchorPosition = blockPos + anchor;
+ }
+ // Qt's idea of the cursor position is the start of the preedit area, so we maintain our own preedit cursor pos
if (!m_composingText.isEmpty())
- realCursorPosition = m_composingCursor;
- QtAndroidInput::updateSelection(realCursorPosition, realCursorPosition, //empty selection
+ realCursorPosition = realAnchorPosition = m_composingCursor;
+ QtAndroidInput::updateSelection(realCursorPosition, realAnchorPosition,
m_composingTextStart, m_composingTextStart + composeLength); // pre-edit text
}
}