Inform android input method when cursor is moved
Google Japanese Input Beta keeps track of the cursor position, and bails out if the cursor is not where it thinks it should be. We have to tell the IM every time we move the cursor, not only when we are composing. Change-Id: I9cdb28f81c76e76d3b0125d08bf0595616ca443f Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
parent
1f180e9690
commit
0c645f1345
@ -337,7 +337,10 @@ void QAndroidInputContext::reset()
|
|||||||
void QAndroidInputContext::commit()
|
void QAndroidInputContext::commit()
|
||||||
{
|
{
|
||||||
finishComposingText();
|
finishComposingText();
|
||||||
|
}
|
||||||
|
|
||||||
|
void QAndroidInputContext::updateCursorPosition()
|
||||||
|
{
|
||||||
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
|
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
|
||||||
if (!query.isNull()) {
|
if (!query.isNull()) {
|
||||||
const int cursorPos = query->value(Qt::ImCursorPosition).toInt();
|
const int cursorPos = query->value(Qt::ImCursorPosition).toInt();
|
||||||
@ -378,6 +381,12 @@ void QAndroidInputContext::showInputPanel()
|
|||||||
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
|
QSharedPointer<QInputMethodQueryEvent> query = focusObjectInputMethodQuery();
|
||||||
if (query.isNull())
|
if (query.isNull())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
disconnect(m_updateCursorPosConnection);
|
||||||
|
if (qGuiApp->focusObject()->metaObject()->indexOfSignal("cursorPositionChanged(int,int)") >= 0) // QLineEdit breaks the pattern
|
||||||
|
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged(int,int)), this, SLOT(updateCursorPosition()));
|
||||||
|
else
|
||||||
|
m_updateCursorPosConnection = connect(qGuiApp->focusObject(), SIGNAL(cursorPositionChanged()), this, SLOT(updateCursorPosition()));
|
||||||
QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
|
QRectF itemRect = qGuiApp->inputMethod()->inputItemRectangle();
|
||||||
QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
|
QRect rect = qGuiApp->inputMethod()->inputItemTransform().mapRect(itemRect).toRect();
|
||||||
QWindow *window = qGuiApp->focusWindow();
|
QWindow *window = qGuiApp->focusWindow();
|
||||||
|
@ -119,10 +119,12 @@ private:
|
|||||||
private slots:
|
private slots:
|
||||||
virtual void sendEvent(QObject *receiver, QInputMethodEvent *event);
|
virtual void sendEvent(QObject *receiver, QInputMethodEvent *event);
|
||||||
virtual void sendEvent(QObject *receiver, QInputMethodQueryEvent *event);
|
virtual void sendEvent(QObject *receiver, QInputMethodQueryEvent *event);
|
||||||
|
void updateCursorPosition();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExtractedText m_extractedText;
|
ExtractedText m_extractedText;
|
||||||
QString m_composingText;
|
QString m_composingText;
|
||||||
|
QMetaObject::Connection m_updateCursorPosConnection;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user