Blame SOURCES/0024-doc-explain-QQItem-event-delivery-handlers-setAccept.patch

383017
From e203a185cfab199a89a33b903096d6d0023a8a88 Mon Sep 17 00:00:00 2001
383017
From: Shawn Rutledge <shawn.rutledge@qt.io>
383017
Date: Wed, 30 Sep 2020 13:51:59 +0200
383017
Subject: [PATCH 24/28] doc: explain QQItem event delivery, handlers,
383017
 setAcceptTouchEvents()
383017
383017
We quietly recommended calling setAcceptTouchEvents() in the Qt 5.10
383017
release notes in any Item subclass that wants to receive touch events,
383017
and in the docs for setAcceptTouchEvents() itself; but the message about
383017
the impending behavior change might not have been obvious enough.
383017
In Qt 6 it becomes mandatory, so clearer docs will hopefully help to
383017
stave off bogus bug reports.
383017
383017
We also never had a great overview of event handling from an Item's
383017
perspective; now it's a little better.
383017
383017
Followup to ab91e7fa02a562d80fd0747f28a60e00c3b45a01 and
383017
a97759a336c597327cb82eebc9f45c793aec32c9
383017
383017
[ChangeLog][QtQuick][QQuickItem] When subclassing QQuickItem, you
383017
should call setAcceptTouchEvents(true) if you need the item to receive
383017
touch events. It will be required in Qt 6.
383017
383017
Task-number: QTBUG-87018
383017
Task-number: QTBUG-87082
383017
Change-Id: I1c7a43979e3665778d61949c9d37c1d085ed594b
383017
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
383017
(cherry picked from commit 7c648280bb53c4276ba4ae2abf26d070fedde71a)
383017
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
383017
---
383017
 src/quick/items/qquickitem.cpp | 34 +++++++++++++++++++++++++++++-----
383017
 1 file changed, 29 insertions(+), 5 deletions(-)
383017
383017
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
383017
index ddd67522b9..e02df00595 100644
383017
--- a/src/quick/items/qquickitem.cpp
383017
+++ b/src/quick/items/qquickitem.cpp
383017
@@ -1,9 +1,9 @@
383017
 /****************************************************************************
383017
 **
383017
-** Copyright (C) 2016 The Qt Company Ltd.
383017
+** Copyright (C) 2021 The Qt Company Ltd.
383017
 ** Contact: https://www.qt.io/licensing/
383017
 **
383017
-** This file is part of the QtQuick module of the Qt Toolkit.
383017
+** This file is part of the QtQuick module of the Qt Toolkit.fset
383017
 **
383017
 ** $QT_BEGIN_LICENSE:LGPL$
383017
 ** Commercial License Usage
383017
@@ -1883,7 +1883,23 @@ void QQuickItemPrivate::updateSubFocusItem(QQuickItem *scope, bool focus)
383017
     \endqml
383017
 
383017
 
383017
-    \section2 Key Handling
383017
+    \section2 Event Handling
383017
+
383017
+    All Item-based visual types can use \l {Qt Quick Input Handlers}{Input Handlers}
383017
+    to handle incoming input events (subclasses of QInputEvent), such as mouse,
383017
+    touch and key events. This is the preferred declarative way to handle events.
383017
+
383017
+    An alternative way to handle touch events is to subclass QQuickItem, call
383017
+    setAcceptTouchEvents() in the constructor, and override touchEvent().
383017
+    \l {QEvent::setAccepted()}{Accept} the entire event to stop delivery to
383017
+    items underneath, and to exclusively grab all the event's touch points.
383017
+
383017
+    Likewise, a QQuickItem subclass can call setAcceptedMouseButtons()
383017
+    to register to receive mouse button events, setAcceptHoverEvents()
383017
+    to receive hover events (mouse movements while no button is pressed),
383017
+    and override the virtual functions mousePressEvent(), mouseMoveEvent(), and
383017
+    mouseReleaseEvent(). Those can also accept the event to prevent further
383017
+    delivery and get an implicit grab at the same time.
383017
 
383017
     Key handling is available to all Item-based visual types via the \l Keys
383017
     attached property.  The \e Keys attached property provides basic signals
383017
@@ -7301,7 +7317,9 @@ bool QQuickItem::isAncestorOf(const QQuickItem *child) const
383017
     If an item does not accept the mouse button for a particular mouse event,
383017
     the mouse event will not be delivered to the item and will be delivered
383017
     to the next item in the item hierarchy instead.
383017
-  */
383017
+
383017
+    \sa acceptTouchEvents()
383017
+*/
383017
 Qt::MouseButtons QQuickItem::acceptedMouseButtons() const
383017
 {
383017
     Q_D(const QQuickItem);
383017
@@ -7310,7 +7328,13 @@ Qt::MouseButtons QQuickItem::acceptedMouseButtons() const
383017
 
383017
 /*!
383017
     Sets the mouse buttons accepted by this item to \a buttons.
383017
-  */
383017
+
383017
+    \note In Qt 5, calling setAcceptedMouseButtons() implicitly caused
383017
+    an item to receive touch events as well as mouse events; but it was
383017
+    recommended to call setAcceptTouchEvents() to subscribe for them.
383017
+    In Qt 6, it is necessary to call setAcceptTouchEvents() to continue
383017
+    to receive them.
383017
+*/
383017
 void QQuickItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)
383017
 {
383017
     Q_D(QQuickItem);
383017
-- 
383017
2.31.1
383017