Controls: ignore mouse events unless handling is implemented
In Qt, input events are accepted by default, and item event handlers
ignore the event. Overrides of the event handlers don't have to do
anything explicit to mark events as handled, but can explicitly ignore
events (i.e. such events that hit transparent areas or are from devices
or buttons the item doesn't care about).
Controls, as of d88d9d6342
, always
accepted events, even if they didn't do anything with it. This is
fundamentally breaking event delivery semantics, preventing control
implementations from selectively accepting or ignoring events depending
on event attributes.
Revert that behavior, and ignore events unless the handler override
returns true. Change all existing handlers to return true so that we
don't break existing controls. Controls that don't override handlers
will ignore the event, which will then propagate as per Qt's event
handling semantics.
The odd control out is Pane, which doesn't do anything with events, but
nevertheless returns true to stop propagation to controls covered by it.
In QWidget world we have special attributes for this kind of UI element,
WA_NoMousePropagation and WA_TransparentForMouseEvents. We might need
something similar in Quick to fix the bug that Drawer eats events in the
(invisible) drag margin, preventing controls underneath to receive them
with priority.
Task-number: QTBUG-59141
Change-Id: Ic1a347ce293c8e11dab958c076ee488834060839
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
This commit is contained in:
parent
5065eb3de4
commit
cd08e08ca0
|
@ -138,7 +138,7 @@ void QQuickAbstractButtonPrivate::setMovePoint(const QPointF &point)
|
|||
emit q->pressYChanged();
|
||||
}
|
||||
|
||||
void QQuickAbstractButtonPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickAbstractButtonPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickAbstractButton);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
|
@ -153,9 +153,10 @@ void QQuickAbstractButtonPrivate::handlePress(const QPointF &point, ulong timest
|
|||
startPressAndHold();
|
||||
else
|
||||
stopPressAndHold();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickAbstractButtonPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickAbstractButtonPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickAbstractButton);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -166,9 +167,10 @@ void QQuickAbstractButtonPrivate::handleMove(const QPointF &point, ulong timesta
|
|||
stopPressRepeat();
|
||||
else if (holdTimer > 0 && (!pressed || QLineF(pressPoint, point).length() > QGuiApplication::styleHints()->startDragDistance()))
|
||||
stopPressAndHold();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickAbstractButtonPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickAbstractButtonPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickAbstractButton);
|
||||
// Store this here since the base class' handleRelease clears it.
|
||||
|
@ -216,6 +218,7 @@ void QQuickAbstractButtonPrivate::handleRelease(const QPointF &point, ulong time
|
|||
}
|
||||
|
||||
wasDoubleClick = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickAbstractButtonPrivate::handleUngrab()
|
||||
|
|
|
@ -75,9 +75,9 @@ public:
|
|||
void setPressPoint(const QPointF &point);
|
||||
void setMovePoint(const QPointF &point);
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
virtual bool acceptKeyClick(Qt::Key key) const;
|
||||
|
|
|
@ -273,9 +273,9 @@ public:
|
|||
|
||||
void createDelegateModel();
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void cancelIndicator();
|
||||
|
@ -753,21 +753,23 @@ void QQuickComboBoxPrivate::createDelegateModel()
|
|||
delete oldModel;
|
||||
}
|
||||
|
||||
void QQuickComboBoxPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickComboBoxPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickComboBox);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
q->setPressed(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickComboBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickComboBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickComboBox);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
q->setPressed(q->contains(point));
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickComboBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickComboBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickComboBox);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -775,6 +777,7 @@ void QQuickComboBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
|||
q->setPressed(false);
|
||||
togglePopup(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickComboBoxPrivate::handleUngrab()
|
||||
|
|
|
@ -194,14 +194,17 @@ static void setActiveFocus(QQuickControl *control, Qt::FocusReason reason)
|
|||
control->forceActiveFocus(reason);
|
||||
}
|
||||
|
||||
void QQuickControlPrivate::handlePress(const QPointF &, ulong)
|
||||
bool QQuickControlPrivate::handlePress(const QPointF &, ulong)
|
||||
{
|
||||
Q_Q(QQuickControl);
|
||||
if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease())
|
||||
if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && !QGuiApplication::styleHints()->setFocusOnTouchRelease()) {
|
||||
setActiveFocus(q, Qt::MouseFocusReason);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickControlPrivate::handleMove(const QPointF &point, ulong)
|
||||
bool QQuickControlPrivate::handleMove(const QPointF &point, ulong)
|
||||
{
|
||||
#if QT_CONFIG(quicktemplates2_hover)
|
||||
Q_Q(QQuickControl);
|
||||
|
@ -209,14 +212,19 @@ void QQuickControlPrivate::handleMove(const QPointF &point, ulong)
|
|||
#else
|
||||
Q_UNUSED(point);
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickControlPrivate::handleRelease(const QPointF &, ulong)
|
||||
bool QQuickControlPrivate::handleRelease(const QPointF &, ulong)
|
||||
{
|
||||
Q_Q(QQuickControl);
|
||||
if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && QGuiApplication::styleHints()->setFocusOnTouchRelease())
|
||||
bool accepted = true;
|
||||
if ((focusPolicy & Qt::ClickFocus) == Qt::ClickFocus && QGuiApplication::styleHints()->setFocusOnTouchRelease()) {
|
||||
setActiveFocus(q, Qt::MouseFocusReason);
|
||||
accepted = true;
|
||||
}
|
||||
touchId = -1;
|
||||
return accepted;
|
||||
}
|
||||
|
||||
void QQuickControlPrivate::handleUngrab()
|
||||
|
@ -1969,22 +1977,19 @@ void QQuickControl::hoverLeaveEvent(QHoverEvent *event)
|
|||
void QQuickControl::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_D(QQuickControl);
|
||||
d->handlePress(event->position(), event->timestamp());
|
||||
event->accept();
|
||||
event->setAccepted(d->handlePress(event->position(), event->timestamp()));
|
||||
}
|
||||
|
||||
void QQuickControl::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_D(QQuickControl);
|
||||
d->handleMove(event->position(), event->timestamp());
|
||||
event->accept();
|
||||
event->setAccepted(d->handleMove(event->position(), event->timestamp()));
|
||||
}
|
||||
|
||||
void QQuickControl::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
Q_D(QQuickControl);
|
||||
d->handleRelease(event->position(), event->timestamp());
|
||||
event->accept();
|
||||
event->setAccepted(d->handleRelease(event->position(), event->timestamp()));
|
||||
}
|
||||
|
||||
void QQuickControl::mouseUngrabEvent()
|
||||
|
|
|
@ -92,9 +92,9 @@ public:
|
|||
#if QT_CONFIG(quicktemplates2_multitouch)
|
||||
virtual bool acceptTouch(const QTouchEvent::TouchPoint &point);
|
||||
#endif
|
||||
virtual void handlePress(const QPointF &point, ulong timestamp);
|
||||
virtual void handleMove(const QPointF &point, ulong timestamp);
|
||||
virtual void handleRelease(const QPointF &point, ulong timestamp);
|
||||
virtual bool handlePress(const QPointF &point, ulong timestamp);
|
||||
virtual bool handleMove(const QPointF &point, ulong timestamp);
|
||||
virtual bool handleRelease(const QPointF &point, ulong timestamp);
|
||||
virtual void handleUngrab();
|
||||
|
||||
void mirrorChange() override;
|
||||
|
|
|
@ -113,9 +113,9 @@ public:
|
|||
bool isLargeChange(const QPointF &eventPos, qreal proposedPosition) const;
|
||||
bool isHorizontalOrVertical() const;
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void cancelHandle();
|
||||
|
@ -244,16 +244,17 @@ bool QQuickDialPrivate::isHorizontalOrVertical() const
|
|||
return inputMode == QQuickDial::Horizontal || inputMode == QQuickDial::Vertical;
|
||||
}
|
||||
|
||||
void QQuickDialPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickDialPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickDial);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
pressPoint = point;
|
||||
positionBeforePress = position;
|
||||
q->setPressed(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickDialPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickDialPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickDial);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -270,9 +271,10 @@ void QQuickDialPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
if (!qFuzzyCompare(pos, oldPos))
|
||||
emit q->moved();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickDialPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickDialPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickDial);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -294,6 +296,7 @@ void QQuickDialPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
|||
q->setPressed(false);
|
||||
pressPoint = QPointF();
|
||||
positionBeforePress = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickDialPrivate::handleUngrab()
|
||||
|
|
|
@ -112,9 +112,9 @@ public:
|
|||
void updatePress(const QPointF &pos);
|
||||
void clearPress(bool clicked);
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
static void setContextProperty(QQuickItem *item, const QString &name, const QVariant &value);
|
||||
|
@ -185,25 +185,28 @@ void QQuickMonthGridPrivate::clearPress(bool clicked)
|
|||
pressedItem = nullptr;
|
||||
}
|
||||
|
||||
void QQuickMonthGridPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickMonthGridPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickMonthGrid);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
updatePress(point);
|
||||
if (pressedDate.isValid())
|
||||
pressTimer = q->startTimer(qGuiApp->styleHints()->mousePressAndHoldInterval());
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickMonthGridPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickMonthGridPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
updatePress(point);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickMonthGridPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickMonthGridPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
clearPress(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickMonthGridPrivate::handleUngrab()
|
||||
|
|
|
@ -91,9 +91,9 @@ class QQuickPageIndicatorPrivate : public QQuickControlPrivate
|
|||
Q_DECLARE_PUBLIC(QQuickPageIndicator)
|
||||
|
||||
public:
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
QQuickItem *itemAt(const QPointF &pos) const;
|
||||
|
@ -109,21 +109,27 @@ public:
|
|||
QQuickItem *pressedItem = nullptr;
|
||||
};
|
||||
|
||||
void QQuickPageIndicatorPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickPageIndicatorPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
if (interactive)
|
||||
if (interactive) {
|
||||
updatePressed(true, point);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QQuickPageIndicatorPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickPageIndicatorPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
if (interactive)
|
||||
if (interactive) {
|
||||
updatePressed(true, point);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QQuickPageIndicatorPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickPageIndicatorPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickPageIndicator);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -131,7 +137,9 @@ void QQuickPageIndicatorPrivate::handleRelease(const QPointF &point, ulong times
|
|||
if (pressedItem && contentItem)
|
||||
q->setCurrentIndex(contentItem->childItems().indexOf(pressedItem));
|
||||
updatePressed(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QQuickPageIndicatorPrivate::handleUngrab()
|
||||
|
|
|
@ -249,6 +249,16 @@ void QQuickPanePrivate::updateContentHeight()
|
|||
emit q->contentHeightChanged();
|
||||
}
|
||||
|
||||
/*
|
||||
A pane needs to be opaque to mouse events, so that events don't get
|
||||
propagated through to controls covered by the pane.
|
||||
*/
|
||||
bool QQuickPanePrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
return true;
|
||||
}
|
||||
|
||||
QQuickPane::QQuickPane(QQuickItem *parent)
|
||||
: QQuickControl(*(new QQuickPanePrivate), parent)
|
||||
{
|
||||
|
|
|
@ -81,6 +81,8 @@ public:
|
|||
void updateContentWidth();
|
||||
void updateContentHeight();
|
||||
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
|
||||
bool hasContentWidth = false;
|
||||
bool hasContentHeight = false;
|
||||
qreal contentWidth = 0;
|
||||
|
|
|
@ -383,9 +383,9 @@ public:
|
|||
#if QT_CONFIG(quicktemplates2_multitouch)
|
||||
bool acceptTouch(const QTouchEvent::TouchPoint &point) override;
|
||||
#endif
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void updateHover(const QPointF &pos);
|
||||
|
@ -470,7 +470,7 @@ bool QQuickRangeSliderPrivate::acceptTouch(const QTouchEvent::TouchPoint &point)
|
|||
}
|
||||
#endif
|
||||
|
||||
void QQuickRangeSliderPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickRangeSliderPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickRangeSlider);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
|
@ -529,9 +529,10 @@ void QQuickRangeSliderPrivate::handlePress(const QPointF &point, ulong timestamp
|
|||
if (QQuickItem *handle = otherNode->handle())
|
||||
handle->setZ(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickRangeSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickRangeSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickRangeSlider);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -549,9 +550,10 @@ void QQuickRangeSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
if (!qFuzzyCompare(pressedNode->position(), oldPos))
|
||||
emit pressedNode->moved();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickRangeSliderPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickRangeSliderPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickRangeSlider);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -559,7 +561,7 @@ void QQuickRangeSliderPrivate::handleRelease(const QPointF &point, ulong timesta
|
|||
|
||||
QQuickRangeSliderNode *pressedNode = QQuickRangeSliderPrivate::pressedNode(touchId);
|
||||
if (!pressedNode)
|
||||
return;
|
||||
return true;
|
||||
QQuickRangeSliderNodePrivate *pressedNodePrivate = QQuickRangeSliderNodePrivate::get(pressedNode);
|
||||
|
||||
if (q->keepMouseGrab() || q->keepTouchGrab()) {
|
||||
|
@ -580,6 +582,7 @@ void QQuickRangeSliderPrivate::handleRelease(const QPointF &point, ulong timesta
|
|||
}
|
||||
pressedNode->setPressed(false);
|
||||
pressedNodePrivate->touchId = -1;
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickRangeSliderPrivate::handleUngrab()
|
||||
|
|
|
@ -288,7 +288,7 @@ void QQuickScrollBarPrivate::itemImplicitHeightChanged(QQuickItem *item)
|
|||
emit indicatorButton->implicitIndicatorHeightChanged();
|
||||
}
|
||||
|
||||
void QQuickScrollBarPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickScrollBarPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickScrollBar);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
|
@ -297,7 +297,7 @@ void QQuickScrollBarPrivate::handlePress(const QPointF &point, ulong timestamp)
|
|||
if (decreaseArrow && decreaseArrow->contains(q->mapToItem(decreaseArrow, point + QPointF(0.5, 0.5)))) {
|
||||
indicatorButton->setPressed(true);
|
||||
q->decrease();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -306,7 +306,7 @@ void QQuickScrollBarPrivate::handlePress(const QPointF &point, ulong timestamp)
|
|||
if (increaseArrow && increaseArrow->contains(q->mapToItem(increaseArrow, point + QPointF(0.5, 0.5)))) {
|
||||
increaseObject->setPressed(true);
|
||||
q->increase();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -315,9 +315,10 @@ void QQuickScrollBarPrivate::handlePress(const QPointF &point, ulong timestamp)
|
|||
if (offset < 0 || offset > sz)
|
||||
offset = sz / 2;
|
||||
q->setPressed(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickScrollBarPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickScrollBarPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickScrollBar);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -330,25 +331,26 @@ void QQuickScrollBarPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
* scrollbar gently.
|
||||
*/
|
||||
if (!pressed)
|
||||
return;
|
||||
return true;
|
||||
|
||||
qreal pos = qBound<qreal>(0.0, positionAt(point) - offset, 1.0 - size);
|
||||
if (snapMode == QQuickScrollBar::SnapAlways)
|
||||
pos = snapPosition(pos);
|
||||
q->setPosition(pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickScrollBarPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickScrollBarPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickScrollBar);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
||||
if (orientation == Qt::Vertical) {
|
||||
if (point.y() < q->topPadding() || point.y() >= (q->height() - q->bottomPadding()))
|
||||
return;
|
||||
return true;
|
||||
} else /* orientation == Qt::Horizontal */{
|
||||
if (point.x() < q->leftPadding() || point.x() >= (q->width() - q->rightPadding()))
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
qreal pos = qBound<qreal>(0.0, positionAt(point) - offset, 1.0 - size);
|
||||
|
@ -357,6 +359,7 @@ void QQuickScrollBarPrivate::handleRelease(const QPointF &point, ulong timestamp
|
|||
q->setPosition(pos);
|
||||
offset = 0.0;
|
||||
q->setPressed(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickScrollBarPrivate::handleUngrab()
|
||||
|
|
|
@ -89,9 +89,9 @@ public:
|
|||
void itemImplicitWidthChanged(QQuickItem *item) override;
|
||||
void itemImplicitHeightChanged(QQuickItem *item) override;
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void visualAreaChange(const VisualArea &newVisualArea, const VisualArea &oldVisualArea);
|
||||
|
|
|
@ -100,9 +100,9 @@ public:
|
|||
void setPosition(qreal position);
|
||||
void updatePosition();
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void cancelHandle();
|
||||
|
@ -182,15 +182,16 @@ void QQuickSliderPrivate::updatePosition()
|
|||
setPosition(pos);
|
||||
}
|
||||
|
||||
void QQuickSliderPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSliderPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSlider);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
pressPoint = point;
|
||||
q->setPressed(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSlider);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -204,9 +205,10 @@ void QQuickSliderPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
setPosition(pos);
|
||||
if (!qFuzzyCompare(pos, oldPos))
|
||||
emit q->moved();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSliderPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSliderPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSlider);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -225,6 +227,7 @@ void QQuickSliderPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
|||
q->setKeepMouseGrab(false);
|
||||
q->setKeepTouchGrab(false);
|
||||
q->setPressed(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSliderPrivate::handleUngrab()
|
||||
|
|
|
@ -134,9 +134,9 @@ public:
|
|||
void startPressRepeat();
|
||||
void stopPressRepeat();
|
||||
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
void handleUngrab() override;
|
||||
|
||||
void itemImplicitWidthChanged(QQuickItem *item) override;
|
||||
|
@ -340,7 +340,7 @@ void QQuickSpinBoxPrivate::stopPressRepeat()
|
|||
}
|
||||
}
|
||||
|
||||
void QQuickSpinBoxPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSpinBoxPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSpinBox);
|
||||
QQuickControlPrivate::handlePress(point, timestamp);
|
||||
|
@ -353,9 +353,10 @@ void QQuickSpinBoxPrivate::handlePress(const QPointF &point, ulong timestamp)
|
|||
q->setAccessibleProperty("pressed", pressed);
|
||||
if (pressed)
|
||||
startRepeatDelay();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSpinBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSpinBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSpinBox);
|
||||
QQuickControlPrivate::handleMove(point, timestamp);
|
||||
|
@ -370,9 +371,10 @@ void QQuickSpinBoxPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
q->setAccessibleProperty("pressed", pressed);
|
||||
if (!pressed)
|
||||
stopPressRepeat();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSpinBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSpinBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSpinBox);
|
||||
QQuickControlPrivate::handleRelease(point, timestamp);
|
||||
|
@ -394,6 +396,7 @@ void QQuickSpinBoxPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
|||
|
||||
q->setAccessibleProperty("pressed", false);
|
||||
stopPressRepeat();
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSpinBoxPrivate::handleUngrab()
|
||||
|
|
|
@ -980,7 +980,7 @@ QQuickItem *QQuickSplitViewPrivate::getContentItem()
|
|||
return new QQuickContentItem(q);
|
||||
}
|
||||
|
||||
void QQuickSplitViewPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSplitViewPrivate::handlePress(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSplitView);
|
||||
QQuickContainerPrivate::handlePress(point, timestamp);
|
||||
|
@ -1031,9 +1031,10 @@ void QQuickSplitViewPrivate::handlePress(const QPointF &point, ulong timestamp)
|
|||
<< " size before press=" << m_rightOrBottomItemSizeBeforePress
|
||||
<< " item=" << rightOrBottomItem;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSplitViewPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSplitViewPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
QQuickContainerPrivate::handleMove(point, timestamp);
|
||||
|
||||
|
@ -1043,9 +1044,10 @@ void QQuickSplitViewPrivate::handleMove(const QPointF &point, ulong timestamp)
|
|||
// resizing to be as responsive and smooth as possible.
|
||||
updatePolish();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSplitViewPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSplitViewPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSplitView);
|
||||
QQuickContainerPrivate::handleRelease(point, timestamp);
|
||||
|
@ -1066,6 +1068,7 @@ void QQuickSplitViewPrivate::handleRelease(const QPointF &point, ulong timestamp
|
|||
m_leftOrTopItemSizeBeforePress = 0.0;
|
||||
m_rightOrBottomItemSizeBeforePress = 0.0;
|
||||
q->setKeepMouseGrab(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSplitViewPrivate::itemVisibilityChanged(QQuickItem *item)
|
||||
|
|
|
@ -98,9 +98,9 @@ public:
|
|||
int handleIndexForSplitIndex(int splitIndex) const;
|
||||
|
||||
QQuickItem *getContentItem() override;
|
||||
void handlePress(const QPointF &point, ulong timestamp) override;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handlePress(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
|
||||
void itemVisibilityChanged(QQuickItem *item) override;
|
||||
void itemImplicitWidthChanged(QQuickItem *item) override;
|
||||
|
|
|
@ -88,8 +88,8 @@ public:
|
|||
qreal positionAt(const QPointF &point) const;
|
||||
|
||||
bool canDrag(const QPointF &movePoint) const;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
|
||||
QPalette defaultPalette() const override { return QQuickTheme::palette(QQuickTheme::Switch); }
|
||||
|
||||
|
@ -117,20 +117,22 @@ bool QQuickSwitchPrivate::canDrag(const QPointF &movePoint) const
|
|||
return (pressPos >= 0.0 && pressPos <= 1.0) || (movePos >= 0.0 && movePos <= 1.0);
|
||||
}
|
||||
|
||||
void QQuickSwitchPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSwitchPrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSwitch);
|
||||
QQuickAbstractButtonPrivate::handleMove(point, timestamp);
|
||||
if (q->keepMouseGrab() || q->keepTouchGrab())
|
||||
q->setPosition(positionAt(point));
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSwitchPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSwitchPrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSwitch);
|
||||
QQuickAbstractButtonPrivate::handleRelease(point, timestamp);
|
||||
q->setKeepMouseGrab(false);
|
||||
q->setKeepTouchGrab(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
QQuickSwitch::QQuickSwitch(QQuickItem *parent)
|
||||
|
|
|
@ -85,8 +85,8 @@ public:
|
|||
qreal positionAt(const QPointF &point) const;
|
||||
|
||||
bool canDrag(const QPointF &movePoint) const;
|
||||
void handleMove(const QPointF &point, ulong timestamp) override;
|
||||
void handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
bool handleMove(const QPointF &point, ulong timestamp) override;
|
||||
bool handleRelease(const QPointF &point, ulong timestamp) override;
|
||||
|
||||
QPalette defaultPalette() const override { return QQuickTheme::palette(QQuickTheme::ListView); }
|
||||
|
||||
|
@ -114,20 +114,22 @@ bool QQuickSwitchDelegatePrivate::canDrag(const QPointF &movePoint) const
|
|||
return (pressPos >= 0.0 && pressPos <= 1.0) || (movePos >= 0.0 && movePos <= 1.0);
|
||||
}
|
||||
|
||||
void QQuickSwitchDelegatePrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSwitchDelegatePrivate::handleMove(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSwitchDelegate);
|
||||
QQuickItemDelegatePrivate::handleMove(point, timestamp);
|
||||
if (q->keepMouseGrab() || q->keepTouchGrab())
|
||||
q->setPosition(positionAt(point));
|
||||
return true;
|
||||
}
|
||||
|
||||
void QQuickSwitchDelegatePrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
bool QQuickSwitchDelegatePrivate::handleRelease(const QPointF &point, ulong timestamp)
|
||||
{
|
||||
Q_Q(QQuickSwitchDelegate);
|
||||
QQuickItemDelegatePrivate::handleRelease(point, timestamp);
|
||||
q->setKeepMouseGrab(false);
|
||||
q->setKeepTouchGrab(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
QQuickSwitchDelegate::QQuickSwitchDelegate(QQuickItem *parent)
|
||||
|
|
Loading…
Reference in New Issue