aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickpincharea.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quick/items/qquickpincharea.cpp')
-rw-r--r--src/quick/items/qquickpincharea.cpp47
1 files changed, 24 insertions, 23 deletions
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index 419792aaa5..f741a08512 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -248,14 +248,13 @@ QQuickPinchAreaPrivate::~QQuickPinchAreaPrivate()
QQuickPinchArea::QQuickPinchArea(QQuickItem *parent)
: QQuickItem(*(new QQuickPinchAreaPrivate), parent)
- , _currentWindow(0)
{
Q_D(QQuickPinchArea);
d->init();
setAcceptedMouseButtons(Qt::LeftButton);
setFiltersChildMouseEvents(true);
-#ifdef Q_OS_MAC
- connect(this, &QQuickItem::windowChanged, this, &QQuickPinchArea::setTouchEventsEnabledForWindow);
+#ifdef Q_OS_OSX
+ setAcceptHoverEvents(true); // needed to enable touch events on mouse hover.
#endif
}
@@ -537,37 +536,39 @@ void QQuickPinchArea::itemChange(ItemChange change, const ItemChangeData &value)
QQuickItem::itemChange(change, value);
}
-QQuickPinch *QQuickPinchArea::pinch()
+#ifdef Q_OS_OSX
+void QQuickPinchArea::hoverEnterEvent(QHoverEvent *event)
{
- Q_D(QQuickPinchArea);
- if (!d->pinch)
- d->pinch = new QQuickPinch;
- return d->pinch;
+ Q_UNUSED(event);
+ setTouchEventsEnabled(true);
}
-void QQuickPinchArea::setTouchEventsEnabledForWindow(QWindow *window)
+void QQuickPinchArea::hoverLeaveEvent(QHoverEvent *event)
+{
+ Q_UNUSED(event);
+ setTouchEventsEnabled(false);
+}
+
+void QQuickPinchArea::setTouchEventsEnabled(bool enable)
{
-#ifdef Q_OS_MAC
// Resolve function for enabling touch events from the (cocoa) platform plugin.
typedef void (*RegisterTouchWindowFunction)(QWindow *, bool);
RegisterTouchWindowFunction registerTouchWindow = reinterpret_cast<RegisterTouchWindowFunction>(
QGuiApplication::platformNativeInterface()->nativeResourceFunctionForIntegration("registertouchwindow"));
if (!registerTouchWindow)
- return; // Not necessarily an error, Qt migh be using a different platform plugin.
-
- // Disable touch on the old window, enable on the new window.
- if (_currentWindow)
- registerTouchWindow(_currentWindow, false);
- if (window)
- registerTouchWindow(window, true);
- // Save the current window, setTouchEventsEnabledForWindow will be called
- // with a null window on disable.
- _currentWindow = window;
-#else // Q_OS_MAC
- Q_UNUSED(window)
-#endif
+ return; // Not necessarily an error, Qt might be using a different platform plugin.
+
+ registerTouchWindow(window(), enable);
}
+#endif // Q_OS_OSX
+QQuickPinch *QQuickPinchArea::pinch()
+{
+ Q_D(QQuickPinchArea);
+ if (!d->pinch)
+ d->pinch = new QQuickPinch;
+ return d->pinch;
+}
QT_END_NAMESPACE