diff options
author | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-10-26 15:53:39 +0200 |
---|---|---|
committer | Richard Moe Gustavsen <richard.gustavsen@qt.io> | 2022-11-02 14:59:27 +0100 |
commit | 632e307fad1ede17f6bf6748358a5662e528d88e (patch) | |
tree | 5190d5b59784d8435520412d9e662c03fd6c5a63 /src | |
parent | 2ef4126cb08f8c72ddfa686dca72a1da481bb7cf (diff) |
QQuickItem: don't disable hover if a hover handler is active
QQuickItemPrivate::subtreeHoverEnabled should be true for an item
if the item itself, or any descendants, are listening for hover.
And the item itself is listening for hover if hoverEnabled is
true, or if it has hover handlers.
But QQuickItemPrivate::setHasHoverInChild() didn't take the latter
into account. This meant that if a leaf item with a hover handler
called setHasHoverInChild(false) at runtime (if the _item_ itself
didn't need hover anymore), we also cleared subtreeHoverEnabled for
the handler (unless the item had a descendant that subscribed for hover).
This meant that it would be skipped during hover event delivery.
This patch will make sure that an item cannot set
subtreeHoverEnabled to false if it's in conflict with one of
its hover handlers.
Change-Id: I89fb387430d9de31c5e1f4b137a37620dcc8a55c
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
(cherry picked from commit f0c2fe9b8a9374e63791a7345e3b489ea441df3c)
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 05d4a873f2..a0fa0e6fa3 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7876,6 +7876,9 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover) if (!hasHover && subtreeHoverEnabled) { if (hoverEnabled) return; // nope! sorry, I need hover myself + if (hasEnabledHoverHandlers()) + return; // nope! sorry, this item has enabled HoverHandlers + for (QQuickItem *otherChild : qAsConst(childItems)) { QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild); if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled) |