*/
static QQuickItem *childAt_helper(QQuickItem *item, int x, int y)
{
- if (item->opacity() == 0.0 || !item->isVisible() || !item->isEnabled())
+ if (!item->isVisible() || !item->isEnabled())
return 0;
if (item->flags() & QQuickItem::ItemClipsChildrenToShape) {
Q_Q(QQuickCanvas);
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (itemPrivate->opacity() == 0.0)
- return false;
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(event->windowPos());
Qt::KeyboardModifiers modifiers, bool &accepted)
{
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (itemPrivate->opacity() == 0.0)
- return false;
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(scenePos);
{
Q_Q(QQuickCanvas);
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (itemPrivate->opacity() == 0.0)
- return false;
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(event->posF());
{
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (qFuzzyIsNull(itemPrivate->opacity()))
- return false;
-
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
for (int i=0; i<newPoints.count(); i++) {
QPointF p = item->mapFromScene(newPoints[i].scenePos());
Q_Q(QQuickCanvas);
bool accepted = false;
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (itemPrivate->opacity() == 0.0 || !item->isVisible() || !item->isEnabled())
+ if (!item->isVisible() || !item->isEnabled())
return false;
QPointF p = item->mapFromScene(event->pos());
explicit property changes. In such cases it may be better to use the
\l opacity property instead.)
- Setting this property to \c false automatically causes \l focus to be set
- to \c false, and this item will longer receive mouse and keyboard events.
- (In contrast, setting the \l opacity to 0 does not affect the \l focus
- property and the receiving of key events.)
+ If this property is set to \c false, the item will no longer receive mouse
+ events, but will continue to receive key events and will retain the keyboard
+ \l focus if it has been set. (In contrast, setting the \l enabled property
+ to \c false stops both mouse and keyboard events, and also removes focus
+ from the item.)
\note This property's value is only affected by changes to this property or
the parent's \c visible property. It does not change, for example, if this
item moves off-screen, or if the \l opacity changes to 0.
*/
+/*!
+ \qmlproperty bool QtQuick2::Item::enabled
+
+ This property holds whether the item receives mouse and keyboard events.
+ By default this is true.
+
+ Setting this property directly affects the \c enabled value of child
+ items. When set to \c false, the \c enabled values of all child items also
+ become \c false. When set to \c true, the \c enabled values of child items
+ are returned to \c true, unless they have explicitly been set to \c false.
+
+ Setting this property to \c false automatically causes \l activeFocus to be
+ set to \c false, and this item will longer receive keyboard events.
+*/
/*!
\qmlproperty AnchorLine QtQuick2::Item::anchors.top
\endqml
\endtable
- If an item's opacity is set to 0, the item will no longer receive mouse
- events, but will continue to receive key events and will retain the keyboard
- \l focus if it has been set. (In contrast, setting the \l visible property
- to \c false stops both mouse and keyboard events, and also removes focus
- from the item.)
+ Changing an items opacity will not affect delivery of input events. (In contrast
+ setting \l visible property to \c false stops mouse events, and setting the
+ \l enabled property to \c false stops mouse and keyboard events, and also removes
+ active focus from the item.)
*/
/*!
//But specific to MouseArea, so doesn't belong in canvas
Q_Q(const QQuickMouseArea);
QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item);
- if (itemPrivate->opacity() == 0.0)
- return false;
if (itemPrivate->flags & QQuickItem::ItemClipsChildrenToShape) {
QPointF p = item->mapFromScene(sp);
void reset() {
acceptTouchEvents = acceptMouseEvents = true;
setEnabled(true);
- setOpacity(1.0);
+ setVisible(true);
lastEvent = makeTouchData(QEvent::None, canvas(), 0, QList<QTouchEvent::TouchPoint>());//CHECK_VALID
QFETCH(bool, acceptTouchEvents);
QFETCH(bool, acceptMouseEvents);
QFETCH(bool, enableItem);
- QFETCH(qreal, itemOpacity);
+ QFETCH(bool, showItem);
QQuickCanvas *canvas = new QQuickCanvas;
canvas->resize(250, 250);
topItem->acceptTouchEvents = acceptTouchEvents;
topItem->acceptMouseEvents = acceptMouseEvents;
topItem->setEnabled(enableItem);
- topItem->setOpacity(itemOpacity);
+ topItem->setVisible(showItem);
// single touch to top item, should be received by middle item
QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
middleItem->acceptTouchEvents = acceptTouchEvents;
middleItem->acceptMouseEvents = acceptMouseEvents;
middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
+ middleItem->setVisible(showItem);
// touch top and middle items, bottom item should get all events
QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
// disable bottom item as well
bottomItem->acceptTouchEvents = acceptTouchEvents;
bottomItem->setEnabled(enableItem);
- bottomItem->setOpacity(itemOpacity);
+ bottomItem->setVisible(showItem);
// no events should be received
QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas)
// disable middle item, touch on top item
middleItem->acceptTouchEvents = acceptTouchEvents;
middleItem->setEnabled(enableItem);
- middleItem->setOpacity(itemOpacity);
+ middleItem->setVisible(showItem);
QTest::touchEvent(canvas, touchDevice).press(0, pointInTopItem, canvas);
QTest::qWait(50);
- if (!enableItem || itemOpacity == 0) {
+ if (!enableItem || !showItem) {
// middle item is disabled or has 0 opacity, bottom item receives the event
QVERIFY(topItem->lastEvent.touchPoints.isEmpty());
QVERIFY(middleItem->lastEvent.touchPoints.isEmpty());
QTest::addColumn<bool>("acceptTouchEvents");
QTest::addColumn<bool>("acceptMouseEvents");
QTest::addColumn<bool>("enableItem");
- QTest::addColumn<qreal>("itemOpacity");
+ QTest::addColumn<bool>("showItem");
- QTest::newRow("disable events") << false << false << true << 1.0;
- QTest::newRow("disable item") << true << true << false << 1.0;
- QTest::newRow("opacity of 0") << true << true << true << 0.0;
+ QTest::newRow("disable events") << false << false << true << true;
+ QTest::newRow("disable item") << true << true << false << true;
+ QTest::newRow("hide item") << true << true << true << false;
}
void tst_qquickcanvas::touchEvent_cancel()
evaluate<void>(item, "Drag.active = true");
QCOMPARE(evaluate<bool>(item, "Drag.active"), true);
QCOMPARE(evaluate<bool>(item, "dragActive"), true);
- QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(0));
- QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(0));
- QCOMPARE(dropTarget.enterEvents, 0); QCOMPARE(dropTarget.leaveEvents, 0);
+ QCOMPARE(evaluate<QObject *>(item, "Drag.target"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(evaluate<QObject *>(item, "dragTarget"), static_cast<QObject *>(&dropTarget));
+ QCOMPARE(dropTarget.enterEvents, 1); QCOMPARE(dropTarget.leaveEvents, 0);
evaluate<void>(item, "Drag.active = false");
dropTarget.setOpacity(1.0);