diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-04-24 14:50:34 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-05-06 19:31:53 +0200 |
commit | dfa51b69bf1f7a6bb3acc0b5cf406039a9e05e83 (patch) | |
tree | ba574abbd72d052e4f8115a6d82189d976d650ef /src/quick/items/qquickwindow.cpp | |
parent | c30e03c7d6bb5218f3ab2a12737164722246413a (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
Pick-to: 5.15
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 755e0ddf69..3a1fbd31f1 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1850,6 +1850,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; } |