Skip to content

Commit 4ebc429

Browse files
Lauri MalmiPasi Pentikäinen
Lauri Malmi
authored and
Pasi Pentikäinen
committed
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 <[email protected]> Reviewed-by: Martin Jones <[email protected]> Reviewed-by: Pasi Pentikäinen <[email protected]> (cherry picked from commit f17543a)
1 parent 2410bc4 commit 4ebc429

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/declarative/graphicsitems/qdeclarativetextinput.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,7 +1200,17 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext(
12001200
QGraphicsSceneMouseEvent *event, QEvent::Type eventType)
12011201
{
12021202
#if !defined QT_NO_IM
1203-
if (event->widget() && control->composeMode()) {
1203+
Q_Q(QDeclarativeTextInput);
1204+
1205+
QWidget *widget = event->widget();
1206+
// event->widget() is null, if this is delayed event from QDeclarativeFlickable.
1207+
if (!widget && qApp) {
1208+
QGraphicsView *view = qobject_cast<QGraphicsView*>(qApp->focusWidget());
1209+
if (view && view->scene() && view->scene() == q->scene())
1210+
widget = view->viewport();
1211+
}
1212+
1213+
if (widget && control->composeMode()) {
12041214
int tmp_cursor = xToPos(event->pos().x());
12051215
int mousePos = tmp_cursor - control->cursor();
12061216
if (mousePos < 0 || mousePos > control->preeditAreaText().length()) {
@@ -1210,11 +1220,11 @@ bool QDeclarativeTextInputPrivate::sendMouseEventToInputContext(
12101220
return true;
12111221
}
12121222

1213-
QInputContext *qic = event->widget()->inputContext();
1223+
QInputContext *qic = widget->inputContext();
12141224
if (qic) {
12151225
QMouseEvent mouseEvent(
12161226
eventType,
1217-
event->widget()->mapFromGlobal(event->screenPos()),
1227+
widget->mapFromGlobal(event->screenPos()),
12181228
event->screenPos(),
12191229
event->button(),
12201230
event->buttons(),

0 commit comments

Comments
 (0)