Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qquickpointerdevicehandler.cpp
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <private/qquickitem_p.h>
6#include <QMouseEvent>
7#include <QDebug>
8
10
26{
27}
28
31{
32}
33
34QInputDevice::DeviceTypes QQuickPointerDeviceHandler::acceptedDevices() const
35{
37 return d->acceptedDevices;
38}
39
40QPointingDevice::PointerTypes QQuickPointerDeviceHandler::acceptedPointerTypes() const
41{
43 return d->acceptedPointerTypes;
44}
45
76{
78 return d->acceptedButtons;
79}
80
82{
84 if (d->acceptedButtons == buttons)
85 return;
86
87 d->acceptedButtons = buttons;
89}
90
92{
94 return d->acceptedModifiers;
95}
96
123void QQuickPointerDeviceHandler::setAcceptedDevices(QPointingDevice::DeviceTypes acceptedDevices)
124{
126 if (d->acceptedDevices == acceptedDevices)
127 return;
128
129 d->acceptedDevices = acceptedDevices;
131}
132
162void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QPointingDevice::PointerTypes acceptedPointerTypes)
163{
165 if (d->acceptedPointerTypes == acceptedPointerTypes)
166 return;
167
168 d->acceptedPointerTypes = acceptedPointerTypes;
170}
171
247void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)
248{
250 if (d->acceptedModifiers == acceptedModifiers)
251 return;
252
253 d->acceptedModifiers = acceptedModifiers;
255}
256
258{
261 return false;
262 qCDebug(lcPointerHandlerDispatch) << objectName()
263 << "checking device type" << d->acceptedDevices
264 << "pointer type" << d->acceptedPointerTypes
265 << "modifiers" << d->acceptedModifiers;
266 if (!d->acceptedDevices.testFlag(event->device()->type()))
267 return false;
268 if (!d->acceptedPointerTypes.testFlag(event->pointingDevice()->pointerType()))
269 return false;
270 if (d->acceptedModifiers != Qt::KeyboardModifierMask && event->modifiers() != d->acceptedModifiers)
271 return false;
272 // Some handlers (HoverHandler, PinchHandler) set acceptedButtons to Qt::NoButton to indicate that button state is irrelevant.
273 if (event->pointingDevice()->type() != QPointingDevice::DeviceType::TouchScreen &&
274 acceptedButtons() != Qt::NoButton && event->type() != QEvent::Wheel &&
275 (static_cast<QSinglePointEvent *>(event)->buttons() & acceptedButtons()) == 0 &&
276 (static_cast<QSinglePointEvent *>(event)->button() & acceptedButtons()) == 0)
277 return false;
278 return true;
279}
280
282
283#include "moc_qquickpointerdevicehandler_p.cpp"
QString objectName
the name of this object
Definition qobject.h:94
A base class for pointer events.
Definition qevent.h:73
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
void setAcceptedButtons(Qt::MouseButtons buttons)
QInputDevice::DeviceTypes acceptedDevices
void setAcceptedDevices(QInputDevice::DeviceTypes acceptedDevices)
\qmlproperty flags PointerDeviceHandler::acceptedDevices
QPointingDevice::PointerTypes acceptedPointerTypes
void setAcceptedPointerTypes(QPointingDevice::PointerTypes acceptedPointerTypes)
\qmlproperty flags PointerDeviceHandler::acceptedPointerTypes
void setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)
\qmlproperty flags PointerDeviceHandler::acceptedModifiers
QQuickPointerDeviceHandler(QQuickItem *parent=nullptr)
\qmltype PointerDeviceHandler \qmlabstract
bool wantsPointerEvent(QPointerEvent *event) override
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
virtual bool wantsPointerEvent(QPointerEvent *event)
It is the responsibility of this function to decide whether the event could be relevant at all to thi...
A base class for pointer events containing a single point, such as mouse events.
Definition qevent.h:108
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition qevent.h:116
QPushButton * button
[2]
Combined button and popup list for selecting options.
@ NoButton
Definition qnamespace.h:56
@ KeyboardModifierMask
#define qCDebug(category,...)
struct _cl_event * event
#define emit
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent