summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauri Malmi <ext-lauri.malmi@nokia.com>2012-06-05 10:26:06 +0300
committerPasi Pentikäinen <ext-pasi.a.pentikainen@nokia.com>2012-06-13 10:13:26 +0200
commit4ebc429af10e4255af35e976cce63d55b3908351 (patch)
tree7240b7d6ff5fa3645f927bba0f840eaab62e88ef
parent2410bc406d3ff10dee2a955f97eb49a8d25d8264 (diff)
downloadqt4-tools-4ebc429af10e4255af35e976cce63d55b3908351.tar.gz
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> (cherry picked from commit f17543a1a70675e104f173ef72a33ddd25eacf8d)
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp
index 4264587246..56260eff79 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(),