aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/handlers/qquickpointerdevicehandler.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2018-06-26 20:23:24 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2018-06-29 14:42:18 +0000
commit73258eca7ab7e3981d9f4aaa5484020cb67854a0 (patch)
tree72805a0605bc4c47a27fdf2a9187aca4ed6b593c /src/quick/handlers/qquickpointerdevicehandler.cpp
parentda722fb448f06cf43780e6f857a1ccd9f07176d6 (diff)
Move QQSinglePointHandler::acceptedButtons to QQPointerDeviceHandler
This property must exist in DragHandler, but we're preparing to have DragHandler inherit from MultiPointHandler. So it's no longer true that a MultiPointHandler only handles touch events: if minimumPointCount is set to 1, it can handle the mouse as well. Change-Id: If6432e22b4382e79820c4d993645cf3de3b83d0c Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/quick/handlers/qquickpointerdevicehandler.cpp')
-rw-r--r--src/quick/handlers/qquickpointerdevicehandler.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/quick/handlers/qquickpointerdevicehandler.cpp b/src/quick/handlers/qquickpointerdevicehandler.cpp
index add6513c1a..7b9f6839b1 100644
--- a/src/quick/handlers/qquickpointerdevicehandler.cpp
+++ b/src/quick/handlers/qquickpointerdevicehandler.cpp
@@ -84,6 +84,51 @@ QQuickPointerDevice::PointerTypes QQuickPointerDeviceHandler::acceptedPointerTyp
return d->acceptedPointerTypes;
}
+/*!
+ \qmlproperty int QtQuick::PointerDeviceHandler::acceptedButtons
+
+ The mouse buttons which can activate this Pointer Handler.
+
+ By default, this property is set to \l {QtQuick::MouseEvent::button} {Qt.LeftButton}.
+ It can be set to an OR combination of mouse buttons, and will ignore events
+ from other buttons.
+
+ For example, a control could be made to respond to left and right clicks
+ in different ways, with two handlers:
+
+ \qml
+ Item {
+ TapHandler {
+ onTapped: console.log("left clicked")
+ }
+ TapHandler {
+ acceptedButtons: Qt.RightButton
+ onTapped: console.log("right clicked")
+ }
+ }
+ \endqml
+
+ \note Tapping on a touchscreen or tapping the stylus on a graphics tablet
+ emulates clicking the left mouse button. This behavior can be altered via
+ \l {PointerDeviceHandler::acceptedDevices}{acceptedDevices} or
+ \l {PointerDeviceHandler::acceptedPointerTypes}{acceptedPointerTypes}.
+*/
+Qt::MouseButtons QQuickPointerDeviceHandler::acceptedButtons() const
+{
+ Q_D(const QQuickPointerDeviceHandler);
+ return d->acceptedButtons;
+}
+
+void QQuickPointerDeviceHandler::setAcceptedButtons(Qt::MouseButtons buttons)
+{
+ Q_D(QQuickPointerDeviceHandler);
+ if (d->acceptedButtons == buttons)
+ return;
+
+ d->acceptedButtons = buttons;
+ emit acceptedButtonsChanged();
+}
+
Qt::KeyboardModifiers QQuickPointerDeviceHandler::acceptedModifiers() const
{
Q_D(const QQuickPointerDeviceHandler);