Android: Reset input method when focus changes
Qt Quick does not have the widgets workaround of explicitly hiding the input method on focus out. This fix copies what happens in the iOS port: Commit the current preedit and reset the IM when we see that the focus object changes. Task-number: QTBUG-38047 Change-Id: I30805265286dc650b3734e2a24807cdc8bfbcd16 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
parent
fec19027a5
commit
3f9ad1efd6
src/plugins/platforms/android
@ -338,7 +338,7 @@ static JNINativeMethod methods[] = {
|
||||
|
||||
|
||||
QAndroidInputContext::QAndroidInputContext()
|
||||
: QPlatformInputContext(), m_blockUpdateSelection(false), m_batchEditNestingLevel(0)
|
||||
: QPlatformInputContext(), m_blockUpdateSelection(false), m_batchEditNestingLevel(0), m_focusObject(0)
|
||||
{
|
||||
QtAndroid::AttachedJNIEnv env;
|
||||
if (!env.jniEnv)
|
||||
@ -532,6 +532,18 @@ void QAndroidInputContext::clear()
|
||||
m_extractedText.clear();
|
||||
}
|
||||
|
||||
|
||||
void QAndroidInputContext::setFocusObject(QObject *object)
|
||||
{
|
||||
if (object != m_focusObject) {
|
||||
m_focusObject = object;
|
||||
if (!m_composingText.isEmpty())
|
||||
finishComposingText();
|
||||
reset();
|
||||
}
|
||||
QPlatformInputContext::setFocusObject(object);
|
||||
}
|
||||
|
||||
void QAndroidInputContext::sendEvent(QObject *receiver, QInputMethodEvent *event)
|
||||
{
|
||||
QCoreApplication::sendEvent(receiver, event);
|
||||
|
@ -95,6 +95,7 @@ public:
|
||||
|
||||
bool isComposing() const;
|
||||
void clear();
|
||||
void setFocusObject(QObject *object);
|
||||
|
||||
//---------------//
|
||||
jboolean beginBatchEdit();
|
||||
@ -136,6 +137,7 @@ private:
|
||||
QMetaObject::Connection m_updateCursorPosConnection;
|
||||
bool m_blockUpdateSelection;
|
||||
int m_batchEditNestingLevel;
|
||||
QObject *m_focusObject;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
Loading…
Reference in New Issue
Block a user