From f17543a1a70675e104f173ef72a33ddd25eacf8d Mon Sep 17 00:00:00 2001 From: Lauri Malmi Date: Tue, 5 Jun 2012 10:26:06 +0300 Subject: QDeclarativeTextInput sends delayed mouse events to input context MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QDeclarativeTextInputPrivate::sendMouseEventToInputContext() now forwards also the delayed press events (sent by QDeclarativeFlickable) to Input context. In case of delayed event QWidget pointer in QGraphicsSceneMouseEvent parameter is null and QApplication::focusWidget() is used to obtain QWidget pointer. Task-number: ou1cimx1#1001264 Change-Id: Ia595af651c322b0c91f3a2bd93a9ac1111a00cf6 Reviewed-by: Pauli Järvinen Reviewed-by: Martin Jones Reviewed-by: Pasi Pentikäinen --- src/declarative/graphicsitems/qdeclarativetextinput.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index d8d2ac9..5fd5e30 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -1200,7 +1200,17 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext( QGraphicsSceneMouseEvent *event, QEvent::Type eventType) { #if !defined QT_NO_IM - if (event->widget() && control->composeMode()) { + Q_Q(QDeclarativeTextInput); + + QWidget *widget = event->widget(); + // event->widget() is null, if this is delayed event from QDeclarativeFlickable. + if (!widget && qApp) { + QGraphicsView *view = qobject_cast(qApp->focusWidget()); + if (view && view->scene() && view->scene() == q->scene()) + widget = view->viewport(); + } + + if (widget && control->composeMode()) { int tmp_cursor = xToPos(event->pos().x()); int mousePos = tmp_cursor - control->cursor(); if (mousePos < 0 || mousePos > control->preeditAreaText().length()) { @@ -1210,11 +1220,11 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext( return true; } - QInputContext *qic = event->widget()->inputContext(); + QInputContext *qic = widget->inputContext(); if (qic) { QMouseEvent mouseEvent( eventType, - event->widget()->mapFromGlobal(event->screenPos()), + widget->mapFromGlobal(event->screenPos()), event->screenPos(), event->button(), event->buttons(), -- cgit v0.12