diff options
author | Lauri Malmi <ext-lauri.malmi@nokia.com> | 2012-06-05 07:26:06 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-06-07 09:27:22 (GMT) |
commit | f17543a1a70675e104f173ef72a33ddd25eacf8d (patch) | |
tree | b71ac1a0522796d42964edb377e531cd7c524e70 | |
parent | 90eadd0c4b6de7d1ab4ba3472ffb9afe1539194c (diff) | |
download | Qt-f17543a1a70675e104f173ef72a33ddd25eacf8d.zip Qt-f17543a1a70675e104f173ef72a33ddd25eacf8d.tar.gz Qt-f17543a1a70675e104f173ef72a33ddd25eacf8d.tar.bz2 |
QDeclarativeTextInput sends delayed mouse events to input context
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 <ext-pauli.p.jarvinen@nokia.com>
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Reviewed-by: Pasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativetextinput.cpp | 16 |
1 files 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<QGraphicsView*>(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(), |