Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
28
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
126void QQuickPointerDeviceHandler::setAcceptedDevices(QPointingDevice::DeviceTypes acceptedDevices)
127{
129 if (d->acceptedDevices == acceptedDevices)
130 return;
131
132 d->acceptedDevices = acceptedDevices;
134}
135
165void QQuickPointerDeviceHandler::setAcceptedPointerTypes(QPointingDevice::PointerTypes acceptedPointerTypes)
166{
168 if (d->acceptedPointerTypes == acceptedPointerTypes)
169 return;
170
171 d->acceptedPointerTypes = acceptedPointerTypes;
173}
174
250void QQuickPointerDeviceHandler::setAcceptedModifiers(Qt::KeyboardModifiers acceptedModifiers)
251{
253 if (d->acceptedModifiers == acceptedModifiers)
254 return;
255
256 d->acceptedModifiers = acceptedModifiers;
258}
259
261{
264 return false;
265 qCDebug(lcPointerHandlerDispatch) << objectName()
266 << "checking device type" << d->acceptedDevices
267 << "pointer type" << d->acceptedPointerTypes
268 << "modifiers" << d->acceptedModifiers;
269 if (!d->acceptedDevices.testFlag(event->device()->type()))
270 return false;
271 if (!d->acceptedPointerTypes.testFlag(event->pointingDevice()->pointerType()))
272 return false;
273 if (d->acceptedModifiers != Qt::KeyboardModifierMask && event->modifiers() != d->acceptedModifiers)
274 return false;
275 // Some handlers (HoverHandler, PinchHandler) set acceptedButtons to Qt::NoButton to indicate that button state is irrelevant.
276 if (event->pointingDevice()->type() != QPointingDevice::DeviceType::TouchScreen &&
277 acceptedButtons() != Qt::NoButton && event->type() != QEvent::Wheel &&
278 (static_cast<QSinglePointEvent *>(event)->buttons() & acceptedButtons()) == 0 &&
279 (static_cast<QSinglePointEvent *>(event)->button() & acceptedButtons()) == 0)
280 return false;
281 return true;
282}
283
285
286#include "moc_qquickpointerdevicehandler_p.cpp"
QString objectName
the name of this object
Definition qobject.h:107
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:63
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:109
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition qevent.h:117
QPushButton * button
[2]
Combined button and popup list for selecting options.
@ NoButton
Definition qnamespace.h:57
@ KeyboardModifierMask
#define qCDebug(category,...)
struct _cl_event * event
#define emit