From cafc2a861b139c33d3989c625deb76a874159fbe Mon Sep 17 00:00:00 2001 From: axis Date: Fri, 5 Feb 2010 13:53:12 +0100 Subject: Fixed a bug where text would disappear in password fields. There were two bugs: - First, we need to avoid triggering the CancelTransaction call when committing the temporary preedit text, because otherwise FEP starts sending us spurious backspace events. Since the "triggeredBySymbian" variable is no longer descriptive for that use case, I renamed it in the process and that changed the negation of the flag. Notice the absense of a change inside commitTemporaryPreeditString(). That is because we want that one to avoid the transaction cancel, and therefore wee keep the old negation. - Second, m_cursorPos needs to be kept in sync with the widget state when we send the temporary preedit string, because the input context cannot separate between types of preedit text when it hits the first block in commitCurrentString() (types being either our temporary text, or FEP's text), and we have to avoid the longPress code path. RevBy: Janne Koskinen --- src/gui/inputmethod/qcoefepinputcontext_p.h | 2 +- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index f325fb9..d5243c3 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -96,7 +96,7 @@ protected: void timerEvent(QTimerEvent *timerEvent); private: - void commitCurrentString(bool triggeredBySymbian); + void commitCurrentString(bool cancelFepTransaction); void updateHints(bool mustUpdateInputCapabilities); void applyHints(Qt::InputMethodHints hints); void applyFormat(QList *attributes); diff --git a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp index 41481d0..2b91711 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -100,7 +100,7 @@ QCoeFepInputContext::~QCoeFepInputContext() void QCoeFepInputContext::reset() { - commitCurrentString(false); + commitCurrentString(true); } void QCoeFepInputContext::ReportAknEdStateEvent(MAknEdStateObserver::EAknEdwinStateEvent aEventType) @@ -125,7 +125,7 @@ void QCoeFepInputContext::update() void QCoeFepInputContext::setFocusWidget(QWidget *w) { - commitCurrentString(false); + commitCurrentString(true); QInputContext::setFocusWidget(w); @@ -218,7 +218,7 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) break; case Qt::Key_Select: if (!m_preeditString.isEmpty()) { - commitCurrentString(false); + commitCurrentString(true); return true; } break; @@ -230,6 +230,7 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) && focusWidget()->inputMethodHints() & Qt::ImhHiddenText && !keyEvent->text().isEmpty()) { // Send some temporary preedit text in order to make text visible for a moment. + m_cursorPos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); m_preeditString = keyEvent->text(); QList attributes; QInputMethodEvent imEvent(m_preeditString, attributes); @@ -292,7 +293,7 @@ void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event) Q_ASSERT(focusWidget()); if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) { - commitCurrentString(false); + commitCurrentString(true); int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); QList attributes; @@ -738,16 +739,16 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin void QCoeFepInputContext::DoCommitFepInlineEditL() { - commitCurrentString(true); + commitCurrentString(false); } -void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian) +void QCoeFepInputContext::commitCurrentString(bool cancelFepTransaction) { int longPress = 0; if (m_preeditString.size() == 0) { QWidget *w = focusWidget(); - if (triggeredBySymbian && w) { + if (!cancelFepTransaction && w) { // We must replace the last character only if the input box has already accepted one if (w->inputMethodQuery(Qt::ImCursorPosition).toInt() != m_cursorPos) longPress = 1; @@ -764,7 +765,7 @@ void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian) m_hasTempPreeditString = false; longPress = 0; - if (!triggeredBySymbian) { + if (cancelFepTransaction) { CCoeFep* fep = CCoeEnv::Static()->Fep(); if (fep) fep->CancelTransaction(); -- cgit v0.12