From ca9e2a0d7488cbbb94d8343c43eb49c6ee5f6519 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 24 Mar 2017 07:44:14 +0100 Subject: Add HoverHandler to detect a hovering mouse pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Detect whether the handler's parent contains the mouse, while the point property tracks the event point (position etc.) Task-number: QTBUG-68072 Change-Id: Ica99332596eab3e344852a11f1ceb7aaf6348c86 Reviewed-by: Qt CI Bot Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickitem.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/quick/items/qquickitem.cpp') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 01413385d9..3b1402fe16 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -67,6 +67,7 @@ #include #include #include +#include #include #include @@ -7342,6 +7343,8 @@ void QQuickItemPrivate::setHasHoverInChild(bool hasHover) QQuickItemPrivate *otherChildPrivate = QQuickItemPrivate::get(otherChild); if (otherChildPrivate->subtreeHoverEnabled || otherChildPrivate->hoverEnabled) return; // nope! sorry, something else wants it kept on. + if (otherChildPrivate->hasHoverHandlers()) + return; // nope! sorry, we have pointer handlers which are interested. } } @@ -8095,6 +8098,16 @@ bool QQuickItemPrivate::hasPointerHandlers() const return extra.isAllocated() && !extra->pointerHandlers.isEmpty(); } +bool QQuickItemPrivate::hasHoverHandlers() const +{ + if (!hasPointerHandlers()) + return false; + for (QQuickPointerHandler *h : extra->pointerHandlers) + if (qmlobject_cast(h)) + return true; + return false; +} + #if QT_CONFIG(quick_shadereffect) QQuickItemLayer::QQuickItemLayer(QQuickItem *item) : m_item(item) -- cgit v1.2.3