aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickwindow.cpp
diff options
context:
space:
mode:
authorVolker Hilsheimer <volker.hilsheimer@qt.io>2020-04-24 14:50:34 +0200
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2020-05-19 06:20:27 +0200
commit6b0f778115a15dd9030820389edf155546d54e35 (patch)
tree58527864bedac1b141049a17990d68672780ef4e /src/quick/items/qquickwindow.cpp
parent706918472f01a0fea51ea450953d878a1f3f003f (diff)
QQuickWindow: pass InputMethod(Query) events on to items
The events were not handled at all on window level, so input from e.g the macOS Emoji keyboard never arrived in the Qt Quick items. Since the input method is likely to use a separate window, the QQuickWindow is likely to not have an active focus item when the input method event arrives. In order to deliver the event to the correct item, walk the scopedFocusItem chain starting with the contentItem as a fall back. [ChangeLog][QtQuick][QtQuickWindow] Pass input method events on to the focus item. Change-Id: I452bb73e13f9cd398c2302303f52a92bda2bb0e3 Fixes: QTBUG-70319 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> (cherry picked from commit dfa51b69bf1f7a6bb3acc0b5cf406039a9e05e83)
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r--src/quick/items/qquickwindow.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 2bdc56e6da..09be88f988 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -1771,6 +1771,25 @@ bool QQuickWindow::event(QEvent *e)
if (d->contentItem)
QCoreApplication::sendEvent(d->contentItem, e);
break;
+ case QEvent::InputMethod:
+ case QEvent::InputMethodQuery:
+ {
+ QQuickItem *target = d->activeFocusItem;
+ // while an input method delivers the event, this window might still be inactive
+ if (!target) {
+ target = d->contentItem;
+ if (!target || !target->isEnabled())
+ break;
+ // see setFocusInScope for a similar loop
+ while (target->isFocusScope() && target->scopedFocusItem() && target->scopedFocusItem()->isEnabled())
+ target = target->scopedFocusItem();
+ }
+ if (target) {
+ QCoreApplication::sendEvent(target, e);
+ return true;
+ }
+ }
+ break;
default:
break;
}