diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2018-03-19 12:02:44 +0100 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2018-03-22 06:58:42 +0000 |
commit | 1f118ce85b8c29d713d2feae529ec8a71ba28048 (patch) | |
tree | a00fc88c01b89dd0b48b8d0c9ac9853a57091e1c /src/quicktemplates2/qquickshortcutcontext.cpp | |
parent | bb30edf15815006bac3ecddfa958055a92057600 (diff) |
Fix Shortcuts in Popups with window context not being activated
Before this patch, this code wouldn't work:
Popup {
id: popup
Shortcut {
sequence: "Tab"
onActivated: popup.visible = !popup.visible
}
}
Even though Popup is aware of its Window, the Shortcut object is
parented to Popup::contentItem, which does not have a Window associated
with it while the Popup is hidden.
The fix is to check if the item has a window in
QQuickShortcutContext::matcher(), so that that check fails and the
QQuickPopup itself is used to access the window.
Change-Id: Ia1c5d75ad6b82fb4c8b7664b6d418d84428b1ddf
Reviewed-by: J-P Nurmi <jpnurmi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickshortcutcontext.cpp')
-rw-r--r-- | src/quicktemplates2/qquickshortcutcontext.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/quicktemplates2/qquickshortcutcontext.cpp b/src/quicktemplates2/qquickshortcutcontext.cpp index e94de722..4e4b46fa 100644 --- a/src/quicktemplates2/qquickshortcutcontext.cpp +++ b/src/quicktemplates2/qquickshortcutcontext.cpp @@ -77,7 +77,7 @@ bool QQuickShortcutContext::matcher(QObject *obj, Qt::ShortcutContext context) case Qt::WindowShortcut: while (obj && !obj->isWindowType()) { item = qobject_cast<QQuickItem *>(obj); - if (item) { + if (item && item->window()) { obj = item->window(); break; } else if (QQuickPopup *popup = qobject_cast<QQuickPopup *>(obj)) { |