From 8c265860b41214daade7c8a28237c1e07ea71a3c Mon Sep 17 00:00:00 2001 From: axis Date: Tue, 9 Jun 2009 14:35:40 +0200 Subject: Fixed the mouse handler of FEP when in inline edit mode. We now commit the text if the mouse handler is invoked. This prevents the case where the VK cannot be brought up because the widget is the only focusable widget and is stuck in inline edit mode. --- src/gui/inputmethod/qcoefepinputcontext_p.h | 2 +- src/gui/inputmethod/qcoefepinputcontext_s60.cpp | 71 ++++++------------------- 2 files changed, 18 insertions(+), 55 deletions(-) diff --git a/src/gui/inputmethod/qcoefepinputcontext_p.h b/src/gui/inputmethod/qcoefepinputcontext_p.h index c2677b1..b33489e 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_p.h +++ b/src/gui/inputmethod/qcoefepinputcontext_p.h @@ -92,7 +92,7 @@ public: TCoeInputCapabilities inputCapabilities(); private: - void commitCurrentString(); + void commitCurrentString(bool triggeredBySymbian); void updateHints(); 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 0a5fd22..1dfb012 100644 --- a/src/gui/inputmethod/qcoefepinputcontext_s60.cpp +++ b/src/gui/inputmethod/qcoefepinputcontext_s60.cpp @@ -123,9 +123,7 @@ void QCoeFepInputContext::update() void QCoeFepInputContext::setFocusWidget(QWidget *w) { - commitCurrentString(); - - CCoeEnv::Static()->Fep()->CancelTransaction(); + commitCurrentString(false); QInputContext::setFocusWidget(w); @@ -292,56 +290,17 @@ bool QCoeFepInputContext::filterEvent(const QEvent *event) void QCoeFepInputContext::mouseHandler( int x, QMouseEvent *event) { Q_ASSERT(m_isEditing); + Q_ASSERT(focusWidget()); - if (!m_pointerHandler) { - QInputContext::mouseHandler(x, event); - } - - TPointerEvent::TType type; - TUint modifiers = 0; - - if (event->type() == QEvent::MouseButtonPress) { - if (event->button() == Qt::LeftButton) { - type = TPointerEvent::EButton1Down; - } else if (event->button() == Qt::RightButton) { - type = TPointerEvent::EButton3Down; - } else if (event->button() == Qt::MidButton) { - type = TPointerEvent::EButton2Down; - } else { - return; - } - } else if (event->type() == QEvent::MouseButtonRelease) { - if (event->button() == Qt::LeftButton) { - type = TPointerEvent::EButton1Up; - } else if (event->button() == Qt::RightButton) { - type = TPointerEvent::EButton3Up; - } else if (event->button() == Qt::MidButton) { - type = TPointerEvent::EButton2Up; - } else { - return; - } - } else if (event->type() == QEvent::MouseMove) { - type = TPointerEvent::EMove; - } else if (event->type() == QEvent::DragMove) { - type = TPointerEvent::EDrag; - } else { - return; - } + if (event->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton) { + commitCurrentString(false); + int pos = focusWidget()->inputMethodQuery(Qt::ImCursorPosition).toInt(); - if (event->modifiers() & Qt::ShiftModifier) { - modifiers |= EModifierShift; - } - if (event->modifiers() & Qt::AltModifier) { - modifiers |= EModifierAlt; + QList attributes; + attributes << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, pos + x, 0, QVariant()); + QInputMethodEvent event("", attributes); + sendEvent(event); } - if (event->modifiers() & Qt::ControlModifier) { - modifiers |= EModifierCtrl; - } - if (event->modifiers() & Qt::KeypadModifier) { - modifiers |= EModifierKeypad; - } - - m_pointerHandler->HandlePointerEventInInlineTextL(type, modifiers, x); } TCoeInputCapabilities QCoeFepInputContext::inputCapabilities() @@ -712,12 +671,10 @@ void QCoeFepInputContext::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLin void QCoeFepInputContext::DoCommitFepInlineEditL() { - commitCurrentString(); - - m_isEditing = false; + commitCurrentString(true); } -void QCoeFepInputContext::commitCurrentString() +void QCoeFepInputContext::commitCurrentString(bool triggeredBySymbian) { if (m_preeditString.size() == 0) { return; @@ -728,6 +685,12 @@ void QCoeFepInputContext::commitCurrentString() event.setCommitString(m_preeditString, 0, 0);//m_preeditString.size()); m_preeditString.clear(); sendEvent(event); + + m_isEditing = false; + + if (!triggeredBySymbian) { + CCoeEnv::Static()->Fep()->CancelTransaction(); + } } MCoeFepAwareTextEditor_Extension1* QCoeFepInputContext::Extension1(TBool& aSetToTrue) -- cgit v0.12