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>
This commit is contained in:
parent
262d2cba12
commit
b732e56969
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user