#ifndef QT_NO_DRAGANDDROP
, drag(0)
#endif
+#ifndef QT_NO_CURSOR
+ , cursor(0)
+#endif
{
}
#ifndef QT_NO_DRAGANDDROP
delete drag;
#endif
+#ifndef QT_NO_CURSOR
+ delete cursor;
+#endif
}
void QQuickMouseAreaPrivate::init()
d->hovered = h;
emit hoveredChanged();
d->hovered ? emit entered() : emit exited();
+#ifndef QT_NO_CURSOR
+ if (d->cursor) {
+ if (d->hovered) {
+ canvas()->setCursor(QCursor(*d->cursor));
+ } else {
+ canvas()->unsetCursor();
+ }
+ }
+#endif
}
}
+
/*!
\qmlproperty QtQuick2::Qt::MouseButtons MouseArea::acceptedButtons
This property holds the mouse buttons that the mouse area reacts to.
return false;
}
+
+/*!
+ \qmlproperty QtQuick2::Qt::CursorShape MouseArea::cursorShape
+ This property holds the cursor shape for this mouse area.
+ Note that on platforms that do not display a mouse cursor this may have
+ no effect.
+
+ The available cursor shapes are:
+ \list
+ \li Qt.ArrowCursor
+ \li Qt.UpArrowCursor
+ \li Qt.CrossCursor
+ \li Qt.WaitCursor
+ \li Qt.IBeamCursor
+ \li Qt.SizeVerCursor
+ \li Qt.SizeHorCursor
+ \li Qt.SizeBDiagCursor
+ \li Qt.SizeFDiagCursor
+ \li Qt.SizeAllCursor
+ \li Qt.BlankCursor
+ \li Qt.SplitVCursor
+ \li Qt.SplitHCursor
+ \li Qt.PointingHandCursor
+ \li Qt.ForbiddenCursor
+ \li Qt.WhatsThisCursor
+ \li Qt.BusyCursor
+ \li Qt.OpenHandCursor
+ \li Qt.ClosedHandCursor
+ \li Qt.DragCopyCursor
+ \li Qt.DragMoveCursor
+ \li Qt.DragLinkCursor
+ \endlist
+
+ In order to only set a mouse cursor shape for a region without reacting
+ to mouse events set the acceptedButtons to none:
+
+ \code
+ MouseArea { cursorShape: Qt.IBeamCursor; acceptedButtons: Qt.NoButton }
+ \endcode
+
+ The default value is \c Qt.ArrowCursor.
+ \sa Qt::CursorShape
+*/
+
+#ifndef QT_NO_CURSOR
+Qt::CursorShape QQuickMouseArea::cursorShape() const
+{
+ Q_D(const QQuickMouseArea);
+ if (d->cursor)
+ return d->cursor->shape();
+ return Qt::ArrowCursor;
+}
+
+void QQuickMouseArea::setCursorShape(Qt::CursorShape shape)
+{
+ Q_D(QQuickMouseArea);
+ setHoverEnabled(true);
+ delete d->cursor;
+ d->cursor = new QCursor(shape);
+}
+#endif
+
/*!
\qmlproperty Item QtQuick2::MouseArea::drag.target
\qmlproperty bool QtQuick2::MouseArea::drag.active
#endif
Q_PROPERTY(bool preventStealing READ preventStealing WRITE setPreventStealing NOTIFY preventStealingChanged)
Q_PROPERTY(bool propagateComposedEvents READ propagateComposedEvents WRITE setPropagateComposedEvents NOTIFY propagateComposedEventsChanged)
+#ifndef QT_NO_CURSOR
+ Q_PROPERTY(Qt::CursorShape cursorShape READ cursorShape WRITE setCursorShape NOTIFY cursorShapeChanged)
+#endif
public:
QQuickMouseArea(QQuickItem *parent=0);
bool propagateComposedEvents() const;
void setPropagateComposedEvents(bool propagate);
+#ifndef QT_NO_CURSOR
+ Qt::CursorShape cursorShape() const;
+ void setCursorShape(Qt::CursorShape shape);
+#endif
+
Q_SIGNALS:
void hoveredChanged();
void pressedChanged();
void enabledChanged();
void acceptedButtonsChanged();
void hoverEnabledChanged();
+#ifndef QT_NO_CURSOR
+ void cursorShapeChanged();
+#endif
void positionChanged(QQuickMouseEvent *mouse);
void mouseXChanged(QQuickMouseEvent *mouse);
void mouseYChanged(QQuickMouseEvent *mouse);